[Resolved] How to create model from existing database Entity Framework Core (ef core)?


 

[SOLVED] With Entity Framework Core (EF Core), how do you generate the EF model and the entities?

Scaffold-DbContext

Generate code for all tables in the database using Ef Core:

Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables "Blog","Post" -ContextDir Context -Context BlogContext -ContextNamespace New.Namespace

Generate code for specific tables selected in the database using Ef Core::

Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables "Blog","Post" -ContextDir Context -Context BlogContext -ContextNamespace New.Namespace

Hope it can help.



Post a Comment

Thank for leaving message

Previous Post Next Post
managed wordpress hosting
managed wordpress hosting