Entity Framework 6 Migrations: How to disable automatic Update-Database on Database initialize?

ef-migrations entity-framework-6

Question

We have a project running EF6 and have now activated Migrations. The problem we have is that we ha a lot of Data that needs to be added to the database when it is created. This worked well until we needed to add data in the migration part so it is part becomes part of the SQL script. Because when we try and create a new database on our development machines the migration steps are done before the Initializer's seed method and some of the data in the migration step depends on that seed data.

Is there some way to just get the initial database, without any migrations, plus the Initializer's seed data? Or do we need to move the critical data to the InitialCreate mirgations Up method?

The production database will cannot be wiped at this stage and thus we need to add all new production data to the migration step.


Edit: In the end we just moved the effected data to the Up method in migrations, not the way I wanted to do it but we where short on time and this solved the problem.

1
0
6/3/2015 2:25:04 PM

Popular Answer

Migrations also have a Seed method you can override that takes place after the Up() method. You can use the AddOrUpdate command in case data may exist. http://www.asp.net/web-api/overview/data/using-web-api-with-entity-framework/part-3

0
5/11/2015 2:09:35 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