ZombieDivision
ZombieDivision

Reputation: 183

Entity framework automation migration

I used to use the command to command line in Entity Framework, which automatically creates models and contexts from the database, I can't find it, could anyone remember remember to link to it?

Upvotes: 0

Views: 105

Answers (2)

Bruno Martins
Bruno Martins

Reputation: 972

You can use the Scaffold-DbContext command.

Here is a nice tutorial about creating your model from existing DB in net core.

A big change though, the old-style EDMX way doesn't exist anymore. As the tutorial says in the end:

Note: Once you have created the model, you must use the Migration commands whenever you change the model to keep the database up to date with the model.

Upvotes: 1

sdi
sdi

Reputation: 52

you mean scaffolding? see https://learn.microsoft.com/en-gb/ef/core/managing-schemas/scaffolding

with .NET cli:

dotnet ef dbcontext scaffold "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Chinook" Microsoft.EntityFrameworkCore.SqlServer

Upvotes: 2

Related Questions