Home / ASP.NET Wiki / Security / Authentication and Authorization / Membership and Roles / How to stop creating the aspnetdb.mdf database

How to stop creating the aspnetdb.mdf database

 Rate It (3)

If you use the asp.net membership providers, having visual studio keep this sql database file around for deployment can sometimes be convenient. However, what if you want to use your own production database specified in the web config for the membership tables and don't want this database to be created everytime you deploy to production? There is a solution to this problem. You simply disable this in the machine.config of your framework version. Here is how to turn this off.

  1. Browse using windows explorer to c:\windows\microsoft.net\framework\your dot net version\config
  2. Open the machine.config file in visual studio or notepad
  3. Scroll down until you get to a line for connectionstrings
  4. Comment out this line
    1. <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
  5. Build your application

Once you delete the aspnetdb.mdf file and rebuild, it shouldn't come back again.

Revision number 2, Friday, January 20, 2012 5:34:01 PM by tmorton

Comments

when site is deployed ,there is no access to machine.config this solution is incorrect ,it's better to solve a problem by this way: in web.config connectionStrings> remove name="LocalSqlServer"/> .. or connectionStrings> clear/> ...

if you modify the machine.config it will effect all the application not instead of one application better to used web.config file instead of machine.config

as suggested use web.config file to remove this section. machine.config file changes apply to all .net application while web.config file is application specific.

if I change machine.config It will affect all apps.

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)