无法检查模型兼容性,因为数据库具有此功能

时间:2014-10-18 13:01:28

标签: asp.net-mvc asp.net-mvc-5 asp.net-identity-2

身份mvc 5中存在问题: 当用户想要查看我的控制者时,我使用[Authorize(Roles =“Admin”)]来登录管理员角色。 因此,当用户重定向到登录页面并登录时,此错误将显示:

Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.

Description: An unhandled exception occurred during the execution of the current web request.         Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.

Source Error: 


Line 73:             // This doen't count login failures towards lockout only two factor authentication
Line 74:             // To enable password failures to trigger lockout, change to shouldLockout: true
Line 75:             var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
Line 76:             switch (result)
Line 77:             {

我的用户是管理员,但我不知道有关此错误的任何事情,值得注意的是我通过nuget使用Asp.Net标识样本。

1 个答案:

答案 0 :(得分:1)

我通过删除身份表来解决我的问题从我的数据库中重建项目并再次运行并创建新用户再次创建表,以便问题得到解决!