2014-10-18 69 views
0

身份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:    { 

我的用户是管理员,但我不知道这个错误的任何东西,值得注意的是,我使用Asp.Net身份通过nuget示例。

回答

1

我解决了我的问题,通过删除标识表从我的数据库和重建项目,再次运行,并创建新的用户再次创建表,以便问题已解决!

相关问题