Rob Bowman
Rob Bowman

Reputation: 8741

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?

Upvotes: 3

Views: 2508

Answers (2)

Rob Bowman
Rob Bowman

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

Related Questions