Reputation: 8741
I have an Asp.Net MVC app for which I'm using entity framework 6 and sql server. I'm not able to run automatic migrations in production so I run the following command to generate a script which I can pass on to the DBA:
update-database -SourceMigration $InitialDatabase -script
This generates a script to create the tables etc but not inserts for the seed data that I have defined in the Seed method of my Configuration class.
Is it possible to have EF generate script for the seed data?
Upvotes: 3
Views: 2508
Reputation: 8741
It turns out EF 6.1.3 (and maybe earlier versions) ships with a tool called migrate.exe that enables the migration to run on the target server along with the data seeding. This is described at the following link and worked well for my problem: https://msdn.microsoft.com/en-gb/data/jj618307.aspx
Upvotes: 3
Reputation: 5312
You have to create custom DB initializer.
http://www.entityframeworktutorial.net/code-first/seed-database-in-code-first.aspx
http://www.asp.net/web-api/overview/data/using-web-api-with-entity-framework/part-3
Upvotes: 1