Can you instruct EF to ignore tables that already exist

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

Question

My application has a one context that is injected using Autofac. I also have plugins which created and maintained their own contexts on the same database. I'm bringing it all in-line now so that the plugins just use the main context.

The issue I now face is that because the tables already exist in the database, I can't update-database because it says PluginTable already exists in the database. I can't do an add-migration and then remove the Up / Down entries because the plugins aren't within the same project.

Note: I think this is only an issue because the tables already exist so I need to get the current migration entries up to date so it doesn't try and recreate the tables.

Note: I considered re-building the migration file but again, the same problem will happen because add migration doesn't work.

I don't know what code to post that will help with this but I'm just wondering if we can tell ef to ignore tables that already exist on its creation process (this sounds daft as I type it but I'm not sure what else to do).

EDIT: Perhaps the question I should be asking is how to get the add-migration to take note of the other projects so I can just do a blank add migration and get the migration file up to date

1
0
11/19/2015 12:49:35 PM

Accepted Answer

Not sure what you mean by the can't add-migration, but if you need to run a migration to establish a baseline:

Add-Migration MyBaseline –IgnoreChanges 

https://msdn.microsoft.com/en-us/data/dn579398.aspx?f=255&MSPPError=-2147217396#option1

2
11/19/2015 8:55:50 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