DB Context has changed
I was working with an example in Entity Framework 5 and ran across this commonly seen issue that DB context has changed, especially after changing my Books model.
The model backing the 'BooksDbContext' context has changed since the database was created. Consider using Code First Migrations
This really mean that my database was unaware that my model was changed. My Books database had to be modified appropriately. Visual Studio offers a package manager that allows us to easily update the database based on the model. This method is the Code First method as opposed to Database First method; I, personally, like the Database First method.
The fix to DB context changing
- Open Tools — Library Package Manager — Package Manager Console
- Type EnableMigrations -ContextTypeName ExampleMVC.Models.BooksDbContext
- Then, do EnableMigrations -EnableAutomaticMigrations
- Type Add-Migration ExampleMVC.Models.BooksDbContext
- Finally, use Update-Database -Verbose
Now run your application and the error should be gone.