繁体   English   中英

如果使用实体连接字符串(与SQL连接字符串一起使用),ASP.NET MVC4简单成员身份无法初始化

[英]ASP.NET MVC4 Simple Membership fails to initialize if using Entity Connection String (works with SQL connection string)

我正在使用Entity Framework 5开发ASP.NET MVC4应用程序,我正在使用Model First模式。

但是,如果我使用设计器生成的连接字符串,则Simple Membership将引发以下错误:

    ......
  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" />

是的,SimpleMembership仅适用于SQL Server连接字符串,因此您需要在web.config中使用此类条目。 不理想,但它可以像你说的那样工作......

这可能是您的答案:首先使用SimpleMembership和EF模型

Jon Galloway的文章是关于SimpleMembership信息的绝佳资源,如果你还没有看到它: http//weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers -and最新-ASP净4-5-web的表单和-ASP净MVC -4- templates.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM