I've recently edited one of models and added some new models to my project. I've typed "add-migration sth" in console and upgraded database. Now when I want to connect to db through my MVC site I get this error:
The current model no longer matches the model used to pre-generate the mapping views, as indicated by the ViewsForBaseEntitySets8f8ed3558b66b3b0b5bd7e2867696566a8a1964469dfa075926133c040704be5.MappingHashValue property. Pre-generated mapping views must be either regenerated using the current model or removed if mapping views generated at runtime should be used instead. See http://go.microsoft.com/fwlink/?LinkId=318050 for more information on Entity Framework mapping views.
I found information that it could be blame of old EF installed, but I think I have the most recent one:
<package id="EntityFramework" version="6.1.2" targetFramework="net45" />
What's wrong? How to fix it?
I see that other people also have the same problem.
The solution is described here: https://msdn.microsoft.com/en-us/data/dn469601.aspx
All you have to do, is to right click on file where you have class with DbContext, choose "Entity Framework" from dropdown menu and then click on "Generate Views".
The reason is: the "Views" file doesn't fit to Model, so you have to simply generate it again using option that I've mentioned here.
Update: Above solution requires EF Power Tools which is unfortunately not supported on Visual Studio 2015. At last officially, because you can install it anyway and here is how: http://thedatafarm.com/data-access/installing-ef-power-tools-into-vs2015/
In case the link doesn't work:
*.vsix
extension. Change it manually to *.zip
extension.vsixmanifest
14.0
version in <SupportedProducts>
(identically as other present versions)
*.vsix
fileFor now I don't know any other easy way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With