2013-03-09 3 views
7

Entity Framework 5でASP.NET MVC4アプリケーションを開発しています。私は、デザイナーによって生成された接続文字列使用している場合エンティティ接続文字列(SQL接続文字列で動作)を使用している場合、ASP.NET MVC4シンプルメンバーシップの初期化に失敗する

しかし簡単な会員は、次のエラーがスローされます。デザイナーによって生成された

...... 
    InnerException: System.InvalidOperationException 
    HResult=-2146233079 
    Message=The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588 
    Source=STD 
    StackTrace: 
     at SistemTempahanDewan.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\Users\Orang\Documents\Visual Studio 2012\Projects\STD\STD\Filters\InitializeSimpleMembershipAttribute.cs:line 45 
    InnerException: System.ArgumentException 
     HResult=-2147024809 
     Message=Unable to find the requested .Net Framework Data Provider. It may not be installed. 
     Source=System.Data 
     StackTrace: 
      at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) 
      at WebMatrix.Data.DbProviderFactoryWrapper.CreateConnection(String connectionString) 
    .... 

接続文字列を(動作しません):

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

接続文字列手動で追加します(動作します):

<add name="STD" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=STD;Integrated Security=True;MultipleActiveResultSets=True" /> 
+0

アセンブリ内のEFおよびSystem.Data.Entityへの参照は間違いありませんか? –

+0

@NeilThompsonそれは他のすべての(表示、編集、作成、削除)データで動作します。シンプルメンバーシップのみがそうではありません。 –

答えて

5

はい、Simp leMembershipはSQL Serverの接続文字列でのみ機能するため、web.configにそのようなエントリが必要です。あなたはすでにそれを見ていない場合Using SimpleMembership with EF model-first

ジョン・ギャロウェイ氏の記事は、SimpleMembershipに関する情報の優れた資源である:あなたが言うように、理想的ではないが、それは

これは、あなたの答えかもしれ...作品http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx

+0

これは設計やバグによるものですか?今のところ私は2つの接続文字列を維持しますが、他の簡単な解決策がないためです。 –

+0

個人的には、さまざまなテクノロジの「集まった」結果として、今サポートされていないと思います(http://odetocode.com/Blogs/scott/archive/2012/09/23/perils-of- the-mvc4-accountcontroller.aspx)。うまくいけば、それは将来のリリースで来るでしょう! –

+1

私は何か間違っていないことを知って安心しています。うまくいけば、これは次のリリースで滑らかにすることができます。リンクありがとう! –

関連する問題