CheGuevarasBeret
CheGuevarasBeret

Reputation: 1414

Entity framework migration and seeding specific update

does anyone know how you can seed a specific update using EF 5 migrations? I have existing database, alredy has lookups populated, and am developing some Audit functionality. I have created an AuditType entity and Audit. When I call update-database, I don't want all my seed data from when I first created the database to be re-added. Do I simply have to manuall delete the existing seed data out or can I do something like name a Configuration.cs with the datetime similar to what gets created when I call add-migration?

Thanks

Upvotes: 24

Views: 32125

Answers (2)

Greg
Greg

Reputation: 2690

You can run a specific migration by specifying the name of the migration. For example, If you have a migration called MyTuesdayMigration.cs, In the package manager console, you would run this command:

update-database -TargetMigration MyTuesdayMigration

Upvotes: 48

foluis
foluis

Reputation: 1048

You may need to delete data so you should use -fore update-database -TargetMigration MigrationName -force

Upvotes: 1

Related Questions