EF6 generate seed data for deployment to production

entity-framework entity-framework-6

Question

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?

1
3
4/1/2016 1:28:29 PM

Accepted Answer

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

3
4/1/2016 2:44:04 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