2014-10-18 75 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

我解決了我的問題,通過刪除標識表從我的數據庫和重建項目,再次運行,並創建新的用戶再次創建表,以便問題已解決!

相關問題