Why is my Entity Framework Migration referring to tables that don't exist?
-
21-12-2019 - |
Question
I cant figure out why my migration code is being created incorrectly. There have been no changes to the database model since I created the database.
Yet if I try creating a migration it fills with code that does not refer to the correct structure.. For example in the Up method I get
DropForeignKey("dbo.Accounts", "BillingAddress_Id", "dbo.Addresses");
when in fact there are no accounts or addresses tables.
I am creating the migration in package manager using add-migration myname -StartUpProjectName UI I have the DataLayer as the default project
Solution
explicitly naming the -project and the -Startupproject parameters seemed to help fix this. i.e
add-migration kfirst -project DataLayer -StartUpProjectName UI
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow