Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Basics Introducing Entity Framework Workflows: Database First

Jose Perez
Jose Perez
1,338 Points

Help please where did you get DatabaseFirstTestDB when selecting database name?

where did you get DatabaseFirstTestDB when selecting database name?

Khoa Nguyen
Khoa Nguyen
4,735 Points

I don't think you need the db since there wasn't anything that you need to do Or you can go into SQL server, create a database, create a table and then try his steps

Robert Patterson
Robert Patterson
2,915 Points

Can use this T-SQL Script to create it (just clone the repository):

https://github.com/guajiropa/Entity-Framework-Basics-DB.git

1 Answer

HIDAYATULLAH ARGHANDABI
HIDAYATULLAH ARGHANDABI
21,058 Points

You can generate via query in DB

USE [Master];
GO
CREATE DATABASE DatabaseFirstTestDB ON ( NAME = DBFirstData, 
                    /* Point to the directory wherer you want to store your db files */
                    FILENAME = 'D:\MSSQL Server Data\DBFirstTest.mdf',
                    SIZE = 10MB,
                    MAXSIZE = 50MB,
                    FILEGROWTH = 5MB )
                    LOG ON ( NAME = DBFirstLog,
                    /* Point to the directory wherer you want to store your db files */ 
                    FILENAME = 'D:\MSSQL Server Data\DBFirstLog.ldf',
                    SIZE = 5MB,
                    MAXSIZE = 25MB,
                    FILEGROWTH = 5MB);
GO
USE [DatabaseFirstTestDB];
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Contact](
    [Id] [int] NOT NULL PRIMARY KEY,
    [Name] [nchar](30) NULL,
    [Nickname] [nchar](30) NULL,
    [Age] [numeric](18, 0) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[ContactAddress](
    [Id] [int] NOT NULL PRIMARY KEY,
    [ContactId] [int] FOREIGN KEY References Contact(Id),
    [AddressLine1] [nchar](20) NULL,
    [AddressLine2] [nchar](20) NULL,
    [City] [nchar](20) NULL,
    [StateProvince] [nchar](10) NULL,
    [PostalCode] [nchar](10) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[ContactEmail](
    [Id] [int] NOT NULL PRIMARY KEY,
    [ContactId] [int] FOREIGN KEY References Contact(Id),
    [Email] [nvarchar](100) NULL
) ON [PRIMARY]
GO