I was asked this question from one of my blog readers: How can a DB be created in SQL Server rather than locally (LocalDb) which is the default?
- <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MvcApplication1-20121005163323;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet- MvcApplication1-20121005163323.mdf" providerName="System.Data.SqlClient" />
Actually, this helps the MVC Application or ASP.NET WebApplication to generate a database locally (within the project's App_Data folder) at run-time for accounts and login management (membership). If however, you want to generate this database in SQL Server then you can make some quick changes in the above Web.config file to do that, so here is what you need to replace in the above db mapping.
- <add name="DefaultConnection" connectionString="Data Source=ITORIAN-PC;Initial Catalog=ASPNETMembership;Integrated Security=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
You probably have a different data source so change it before running. Now, run the application and click on the "Register" link to create an account, and then you are all done.
I hope this helps you. Thanks.



Hamid KhanPosted Mar 25, 2021, 1:01 PM
Thanks for sharing
Akhil MittalPosted Sep 15, 2014, 2:46 AM
How can we integrate this with an existing database? I want to leverage OAuth functionality in my application having database already existing in MySql.How can i do that?
Lakshmi Reddy YeluriPosted Jan 3, 2013, 1:43 PM
Thanks for this
Tina GargPosted Oct 17, 2012, 12:14 AM
Great Abhimanyu.......