From the course: Using Entity Framework Core with Legacy Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Scaffolding an initial model and context

Scaffolding an initial model and context

From the course: Using Entity Framework Core with Legacy Databases

Start my 1-month free trial

Scaffolding an initial model and context

- [Instructor] Entity Framework maps the database to code by combining data models in a DB context. We're going to use the Entity Framework tools on top of the dotnet CLI to scaffold the models and the context from the existing database. To connect to the database we'll need a connection string. For SQL Sever Express we can get a connection string by opening up the SQL Server Object Explorer, dropping down SQL Server and MS SQL Local DB, Databases, and then right click on our database and select properties. From within the properties window we can scroll down to find the connection string, Control A to select all, and Control C to copy. Now we can use Windows R and Command to open up a command window. Navigate to a project folder. And type dotnet ef for Entity Framework, dbcontext and scaffold. Now use double quotes before pasting in the connection string. And then close the double quotes. The next argument is the type of database we'll be using, SQL Server, we need to use the fully…

Contents