The model backing the 'EFDbContext' context has changed error
Following the sports store tutorial in Pro Asp.Net MVC book, I have TWO
projects in my Asp.Net MVC4 solution. One SportsStore.WebUI and one
SportsStore.Domain , which has my Product class below
I added a Required attribute to Name in my model class
//Product.cs class
[Required]
public string Name { get; set; }
//..more properties, not important as I get the same error for all -
because I added Required to all
When I run the project I get The model backing the 'EFDbContext' context
has changed since the database was created. error.
I have checked on stackoverflow and MSDN
Solution 1: Didn't Work
Suggested solution on MSDN was to run Update-Database -Force . That
doesn't work , I get
"Could not load assembly 'SportsStore.WebUI'. (If you are using Code First
Migrations inside Visual Studio this can happen if the startUp project for
your solution does not reference the project that contains your
migrations. You can either change the startUp project for your solution or
use the -StartUpProjectName parameter.)"
That is strange because A- I'm NOT using code first and B-The Domain
project DOES reference WebUI project
Solution 2: Didn't Work
Then I tried Enable-Migrations in the PM console and I get
No context type was found in the assembly 'SportsStore.WebUI'.
I then tried changing the startup project to SportsStore.Domain ( which
has my product class) - nothing, same error
No comments:
Post a Comment