-
-
Notifications
You must be signed in to change notification settings - Fork 300
Reverse Engineering Quick Start
Erik Ejlskov Jensen edited this page Aug 2, 2022
·
16 revisions
This guide walks you through the basic steps of generating a DbContext and entity classes for a SQL Server database. For detailed instructions see the wiki
-
Install EF Core Power Tools via the
Extensions/Manage Extensions
menu inside Visual Studio. -
Right click a project in Solution Explorer, select
EF Core Power Tools/Reverse Engineer
-
Connect to your existing database via the Add button (or pick an existing connection from the drop down list)
- Choose database objects, you can use the top checkbox to select all objects
- Choose options, or just accept the defaults
- Click OK, and C# DbContext and entity classes will be generated in the current project.
You can now start coding with EF Core:
using var db = new ChinookContext();
var hairAlbum = db.Albums.Where(a => a.Title == "Hair").FirstOrDefault();