How to update dbcontext scaffolding in ASP.NET 5 with EF Core?

asp.net asp.net-core c# entity-framework entity-framework-core

Question

I have an ASP.NET 5 EF Core (formerly EF 7) Database First project I'm working on. I've been able to scaffold my database contexts using dnx. Accessing the database in the project is now working well, however I'm wondering what the best process is to mirror changes as my database schema changes.

I've done database migrations using code first and I've updated contexts using an edmx file, but neither option applies here.

I can manually edit the entity files and add new ones to match database changes. Alternatively, I can wipe the dbcontext and its table classes and re-scaffold from scratch each time. However, I would prefer a more automated process, if one exists.

1
5
8/31/2019 8:55:31 AM

Accepted Answer

EntityFramework 7 (soon to be called Entity Framework Core 1.0) supports both creating models from existing database (Database-First) as well as creating database from models (Model-First).

For the initial release, only database creation from model and scaffolding from existing database are planed. Incremental "database-first" are not planned for initial release and it's still open if it will come yet.

What you can do however is to scaffold your database into code and then only use code and migrations to do future updates to the database schema.

EDMX (Model-First, but w/o Code-First) won't be supported at all.

6
2/16/2016 8:33:17 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow