Strategy to maintain DML scripts with code first Entity framework

522 views Asked by At

So I have always worked with a database first approach, maintained scripts in a database project for continuous integration. I have created my code first classes, but I can't understand how will I maintain scripts, should I maintain a database project to do this, seems to be an overhead! Please suggest

Thanks!

1

There are 1 answers

0
Steve Greene On BEST ANSWER

We use migrations. https://msdn.microsoft.com/en-us/data/jj591621.aspx

During development, we turn automatic migrations on and then when we are ready to deploy to TEST/PROD we will create a migration and a script for the DBA similar to the technique described here: http://cpratt.co/migrating-production-database-with-entity-framework-code-first/#at_pco=smlwn-1.0&at_si=54ad5c7b61c48943&at_ab=per-12&at_pos=0&at_tot=1

You may run into issues working in a team environment, but you can work around them: Migrations in Entity Framework in a collaborative environment

Finally, you can configure your CI server to run the migrations. http://www.gitshah.com/2014/06/how-to-run-entity-framework-migrations.html