0

My team has a database generated using Code First Migrations. The database is then populated with another script that can take upwards of an hour to run. I generate a .sql file of those tables with the populated data, this is to help speed up others development process. When the migration is changed I have to redo this entire process. Or the developers changing the migrations get stuck because now EF is out of sync.

Is there a way to tell Entity Framework on Update database that yes these tables exist but just update their structure?

TLDR How can I get EF to run ALTER TABLE instead of CREATE TABLE if the MigrationHistory does not exist.

Steve Greene
  • 12,029
  • 1
  • 33
  • 54
Nick
  • 978
  • 1
  • 12
  • 28
  • EF migrations update database does exactly that - update the structure / schema. Basically, keeps your code first model in sync with database structure. Are you asking that is there a way to keep the scripts (that you manually generated) in sync with the evolving structure?? – Amanvir Mundra May 26 '17 at 05:25
  • I want it to keep the code first model in sync. But if the table exist is should use ALTER TABLE instead of CREATE TABLE. – Nick May 26 '17 at 19:44
  • Not sure what your issue is - EF does a model compare and will only create a table if it did not exist in the prior migration. Perhaps you are dealing with the common issue of using migrations in a team environment described [here](https://msdn.microsoft.com/en-us/library/dn481501(v=vs.113).aspx)? – Steve Greene May 27 '17 at 00:42
  • Hi @Steve Greene your link helped answer my question. – Nick May 31 '17 at 16:55

0 Answers0