Visual Studio database project and Enity Framework code-first

database-projectsentity-frameworkvisual-studio-2013

At work we are developing our latest module in C# Entity framework code-first approach. I have been given the role of developing databases from the DBContexts from within the project/s.

I generated the tables/entities from the DBContext and created database projects and all is fine.

My question is: When a developer changes the DBContext entities or changes a property of an entity, how can I become aware of such changes and update the database projects?

Best Answer

Here is and article explaining a good way to do this will little extra effort. The article describes comparing the SQL Database Project with the EF generated LocalDB to persist schema changes.

Use EF to make schema/entity updates like you would normally in you development workflow. The use the EF database as your comparison DB to update your SQL Database project.

Going the other way means updating objects like stored procedures, logins, additional indexes, and other more administrative/fine tuning objects.

There is a caveat though... EF does not have the tooling to detect these changes automatically, so be disciplined in using the right tools for the right jobs. EF for models and SQL DB Project for... well, everything not controlled with EF code migrations :-)

SQL Database Project and EF