Everything was working just fine
It was such a strange error,, It wasn't my error at the end, it was Microsoft's,, I installed the Entity framework the " pre-release" version and it was responsible for this error,, when i upgraded to the stable release it disapperared,, thank you everyone believe me when i asked this question i searched like for a week or so for its solution so i am pretty sure that this problem isn't anywhere else : the version of entity framework.dll that caused the problem was 6.0.2 if it helps.
Just Delete the migration History in _MigrationHistory in your DataBase. It worked for me
This post fixed my issue. It's all about adding the following line in Application_Start()
in Global.asax
:
Database.SetInitializer<Models.YourDbContext>(null);
However it cause database recreation for every edit in your model and you may loose your data.
Everybody getting a headache from this error: Make absolutely sure all your projetcs have a reference to the same Entity Framework assembly.
Short story long:
My model and my application were in different assemblies. These assemblies were referencing a different version of Entity framework. I guess that the two versions generated a different id for the same modell. So when my application ran the id of the model didn't match the one of the latest migration in __MigrationHistory. After updating all references to the latest EF release the error never showed up again.
I was having same problem as a7madx7, but with stable release of EF (v6.1.1), and found resolution posted in:
http://cybarlab.com/context-has-changed-since-the-database-was-created
with variation in: http://patrickdesjardins.com/blog/the-model-backing-the-context-has-changed-since-the-database-was-created-ef4-3
2nd link includes specific mention for VB..... "you can simply add all the databasecontext that are having this problem on your app_start method in the global.asax file like this":
Database.SetInitializer(Of DatabaseContext)(Nothing)
NB: i had to replace "DatabaseContext" with the name of my class implementing DbContext
Update: Also, when using codefirst approach to connect to existing tables, check database to see if EF has created a table "_migrationhistory" to store mappings. I re-named this table then was able to remove SetInitializer from global.asax.
remove all tables identity
Delete _MigrationHistory
Delete AspNetRoles
Delete AspNetUserClaims
Delete AspNetUserLogins
Delete AspNetRoles
Delete AspNetUser