ASP.NET (MVC) AspNetSqlMembershipProvider and aspnetdb.mdf – use SQL instead

After creating a project, running it I was not able to access to¬†aspnetdb.mdf data. Simply couldn’t open it because of it had incorrect server name set in its connection string setting (web.config was set properly).

Initial connection string:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>

So, instead I set up database and updated Web.config. Database requires all tables and stored procedures to run membership. How to do that without having access to MDF file?

Use aspnet_regsql.exe as
If you are confused with paramters, just run exe without any and you will get access to wizard.

My command:

C:> cd C:WindowsMicrosoft.NETFramework64v4.0.30319
C:> WindowsMicrosoft.NETFramework64v4.0.30319> aspnet_regsql.exe

Leave a Reply

Your email address will not be published. Required fields are marked *