2013-01-03 40 views
0

我的大腦被這個問題攪亂了。Asp.Net MVC4播種用戶和角色教程

我一直在下面的教程上的以下鏈接播種用戶&角色: -

http://blog.longle.net/2012/09/25/seeding-users-and-roles-with-mvc4-simplemembershipprovider-simpleroleprovider-ef5-codefirst-and-custom-user-properties/#comment-648

我得到儘可能嘗試更新數據庫,然後應該種子用戶,但我得到以下錯誤信息: -

必須調用「WebSecurity.InitializeDatabaseConnection」方法 你所說的「WebSecurity」類的任何其他方法之前。此調用 應放置在一個_AppStart.cshtml文件在您網站的根**

另一位成員張貼了這個問題在這裏: - 。Cannot seed Users & Roles

系統提供的分辨率犯規幫助我,因爲我已經獲得了我的項目中引用的正確版本的WebMatrix.WebData.Dll。 (版本2)。

其他人已經能夠按照說明沒有過錯,這是沒有意義的。 O已經嘗試了其他人已經發布的所有工作,但故障不會轉移。

回答

0

我設法通過確保以下參考資料,其中加入到我的Configuration.cs解決這個問題: -

using System; 
    using System.Data.Entity; 
    using System.Data.Entity.Migrations; 
    using System.Linq; 
    using WebMatrix.WebData; 
    using WebMatrix.Data; 
    using System.Web;