-
-
Notifications
You must be signed in to change notification settings - Fork 298
Reverse Engineering Quick Start
Erik Ejlskov Jensen edited this page Aug 31, 2022
·
16 revisions
This guide walks you through the basic steps of generating a DbContext and entity classes for an Azure SQL or SQL Server database. For detailed instructions see the wiki
A 10 minute YouTube based version of this guide is also available.
-
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 and LINQ:
using var db = new ChinookContext();
var hairAlbum = db.Albums.Where(a => a.Title == "Hair").FirstOrDefault();