【发布时间】:2014-12-13 22:06:27
【问题描述】:
identity 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 身份示例。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-5 asp.net-identity-2