2015-10-23 47 views
0

我想在asp.net mvc5空白項目中進行會員工作。我使用db第一種方法,並已安裝apsnet_regsql。在創建vs2012互聯網應用程序並複製模型,篩選器,控制器和視圖中的所有內容後。MVC5空白項目的成員資格

但我遇到了一個問題。當我試圖在登錄(或東西)ACCES它拋出一個異常:

一種類型的「System.ArgumentException」發生在 System.Data.dll中,但在用戶代碼中沒有處理例外

附加信息:無法找到請求的.Net Framework 數據提供程序。它可能沒有安裝。

,這裏是我的ConnectionString:

<add name="CSharpAssignmentDbContext" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=GIORGI\SQLEXPRESS;initial catalog=CSharpAssignmentDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

起初我有一個問題,比我發現here

在你的web應用程序的根目錄中稱爲_AppStart.cshtml和 創建一個文件把它放在裏面:

@{ 
    if (!WebSecurity.Initialized) 
    { 
     WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", 
               "UserName", autoCreateTables: true); 
    } 
} 

它有什麼問題?我使用的是最新的EF 6.1.3 DB頭

+0

看起來你需要使用的NuGet到的EntityFramework安裝到你的Web項目。 – TheGeekYouNeed

+0

@TheGeekYouNeed它已安裝 – gsiradze

回答

0

因爲我發現here

您不能使用的ConnectionString爲別的比EDMX 連接。我的web.config的方式使網站使用 同樣連接字符串的會員資料也不是 與System.Data.EntityClient提供程序兼容,並需要我的情況下 System.Data.Sqlclient。添加第二個連接字符串, 減去其中的實體框架內容,並通過 引用web.config中的成員資格提供程序屬性,刪除所有 錯誤,並允許頁面呈現和請求來自SQL 服務器的內容。

所以我添加第二的ConnectionString

<add name="DefaultConnection" connectionString="Data Source=.\SQLExpress;Initial Catalog=CSharpAssignmentDb;Integrated Security=SSPI;" providerName="System.Data.SqlClient" /> 

它解決我的問題