Code First to existing DB
How-to code-first
Create database schema
Create a new project
Install Entity Framework Core
Reverse engineer your model
Register your context with dependency injection
Reverse engineer your model
Navigate to Tools –> NuGet Package Manager –> Package Manager Console then enter:
The reverse engineer process created entity classes (Blog.cs
& Post.cs
) and a derived context (BloggingContext.cs
) based on the schema of the existing database.
Like this:
Last updated