7

I am developing ASP.NET MVC4 application with Entity Framework 5, and I am using Model First mode.

However Simple Membership will throw the following error if I am using the connection string generated by the designer:

    ......
  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)
    ....

Connection string generated by the designer (will not work):

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

Connection string I add manually (will work):

<add name="STD" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=STD;Integrated Security=True;MultipleActiveResultSets=True" />
Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154

1 Answers1

6

Yes, SimpleMembership only works with SQL Server connection strings, so you need such an entry in your web.config. Not ideal, but it works as you say...

This may be your answer: Using SimpleMembership with EF model-first

Jon Galloway's article is an excellent resource of information about SimpleMembership, if you haven't already seen it: 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

Community
  • 1
  • 1
Alistair Findlay
  • 1,154
  • 6
  • 12
  • So is this by design or a bug? For now I will maintain the 2 connection strings due to the lack of any other simpler solution. – Rosdi Kasim Mar 11 '13 at 15:38
  • Personally, I think it's unsupported just now, as a result of a "coming together" of various technologies (see here: http://odetocode.com/Blogs/scott/archive/2012/09/23/perils-of-the-mvc4-accountcontroller.aspx). Hopefully it'll come with a future release! – Alistair Findlay Mar 11 '13 at 15:43
  • 1
    I am relieved to know that I am not doing something wrong. Hopefully this can be smoothed out in the next release. Thanks for the links! – Rosdi Kasim Mar 12 '13 at 02:28