Can you instruct EF to ignore tables that already exist

c# ef-code-first ef-migrations entity entity-framework-6


One context in my application is injected using Autofac. On the same database, I also have plugins that established and maintained their own contexts. Now that I've brought everything into line, the plugins will only use the primary context.

I now have a problem in that I can't do anything because the tables already exist in the database.update-database since it statesPluginTable existing in the database already. Unable to do anadd-migration due to the fact that the plugins aren't part of the same project, remove the Up / Down entries.

I believe the main problem is that the tables already exist, thus I must update the migration entries now in place to prevent the tables from being attempted to be recreated.

I thought about rebuilding the migration file, but add migration won't work, therefore the issue would still arise.

Although it sounds absurd as I type it, I'm simply wondering whether we can instruct ef to disregard tables that already exist during the creation process. I'm not sure what else to do, and I'm not sure what code to upload that will assist.

EDIT: Possibly I should be asking how to obtain theadd-migration Gotta make a note of the other projects so I can just perform an add migration without any changes and update the migration file.

11/19/2015 12:49:35 PM

Accepted Answer

I'm not sure exactly what you mean by the "can't add-migration," however if you must perform a migration in order to create a baseline:

Add-Migration MyBaseline –IgnoreChanges

11/19/2015 8:55:50 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow