Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF6 generate seed data for deployment to production

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?

like image 930
Rob Bowman Avatar asked Dec 18 '25 06:12

Rob Bowman


1 Answers

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

like image 129
Rob Bowman Avatar answered Dec 20 '25 23:12

Rob Bowman