Search code examples
entity-framework-coreef-code-firstentity-framework-migrationsasp.net-core-2.1database-first

Core 2 Keep domain models in sync with database changes


Need help! I am new to Core 2.0 and VS 2017 and haven't had much experience with MVC. I have an existing database that I need to use with a core 2.0 project at work. I was able to use the Scaffold-DbContect to initially create the domain models from the existing database.

However, the database developers are making changes to the database and adding new tables. I need to keep my domain models in sync with the database changes that are being made.

The only thing I can find on the internet is how to make changes to the model and update the database schema. However, I need to update the model from changes made to the database.


Solution

  • EF Core works on Code First approach. And You guys are following DB First approach together. So you should make changes in your code and then generate migrations accordingly, Otherwise, it will lead you in trouble.

    You can use EF Core Power tool for generating the db changes at code side. But in this case you have to take care while generating migrations from code side.