keeping database in sync ef core

entity-framework-core entity-framework-core-migrations

Question

I have read multiple posts about this but do not have a clear answer yet. We are transitioning to EF Core 2.0 company-wide, one project at a time.

The challenge is this:

  1. A new project starts and a database is created using code first, migrations etc.
  2. another programmer needs to create a project targeting the same database.
  3. This programmer can use Scaffold-DbContext and generate current models.
  4. However, a new column is needed and this second programmer adds it.

Now...how do we best update the other projects? Is there something that checks and syncs or shows what is out of sync between your model and a database? Meaning check the database for changes...not the model.

We don't mind buying a tool if that is the best solution.

1
0
6/7/2018 1:09:43 PM

Accepted Answer

The solution we have been using, very successfully is the Database project in Visual Studio.

Using that each developer has the project in their solution, changes are made against it locally. Then we can do a "Schema Compare" inside of VS.

We have been using this successfully for 4 of us the past three weeks extensively with almost no issues.

This has even worked for keeping versions and changes to our stored procedures current. It works well with VSTS also.

Here are some of the posts I read that helped me understand it:

https://www.sqlchick.com/entries/2016/1/10/why-you-should-use-a-ssdt-database-project-for-your-data-warehouse

https://weblogs.asp.net/gunnarpeipman/using-visual-studio-database-projects-in-real-life

..and this forum had a lot of relevant questions/answers: https://social.msdn.microsoft.com/Forums/sqlserver/en-us/home?forum=ssdt

0
6/30/2018 2:16:32 PM


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