I have a database-first ASP.NET MVC 4 project and would like to use the SimpleMembershipProvider with the custom user_info table in my database. I am using Entitiy Framework 6 with SQL Server. I have scoured the internet and SO for a solution, but with no luck.
My user_info table looks like this:
[Id] INT IDENTITY (1, 1) NOT NULL,
[email] NVARCHAR (MAX) NULL,
[first_name] NVARCHAR (MAX) NULL,
[last_name] NVARCHAR (MAX) NULL,
[internal_role] INT NULL,
CONSTRAINT [PK_user_info] PRIMARY KEY CLUSTERED ([Id] ASC)
I have tried to follow the steps in How can I customize simple membership provider to work with my own database ASP.NET mvc 4, but I don't think this method will work for non-Code-First projects. I get the server error "Unable to find the requested .Net Framework Data Provider. It may not be installed." when I try to add the following code to the function SimpleMembershipInitializer().
WebSecurity.InitializeDatabaseConnection("ReservationSystemEntities", "user_info", "Id", "email", autoCreateTables: true);
Here is the relevant info from my Web.config file:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=xxxxxx" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ReservationSystemEntities" connectionString="metadata=res://*/ReservationSystem.csdl|res://*/ReservationSystem.ssdl|res://*/ReservationSystem.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\v11.0;initial catalog=ReservationSystem;integrated security=True;user id=xxxxx;password=xxxxx;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
I'm not even sure if this is possible, based on this answer: SimpleMembershipInitializer won't initialize
Based on this answer Using MVC 4 SimpleMembership with an existing database-first EF model I need to specify a connection string like this:
<add name="CONNECTION_STRING_NAME" connectionString="data source=SERVER;initial catalog=DATABASE;user id=USER;password=PASSWORD;" providerName="System.Data.SqlClient" />
I'm not sure how to convert my connection string to a connection string like this though. Isn't this type of connection string valid only when using Code-First?
Any help would be much appreciated.