6

My question is stated in the title, to give some background though.

I'm helping a customer use webparts within a ASP.net environment and I don't want them to get attached to this database. I'd like to be able to use the site without it creating this database.

I'm currently researching more into this, but any suggestions on sites to look at or information regarding this will be much appreciated.

Eric
  • 2,202
  • 2
  • 26
  • 30

4 Answers4

5

Most of your configuration is saved in this database. It's created to hold all the complex data that is necessary for membership and personalization to work.

You can point to a different database if you have one set up, but out of the box, Visual Studio uses this local file for the database.

I believe that web parts relies on having the database available, so you'll need to keep this database, or follow the link above to use a centralized database.

http://msdn.microsoft.com/en-us/library/879kf95c(VS.80).aspx

David
  • 72,686
  • 18
  • 132
  • 173
2

I know this is a very old post, but I had basically the same question, "Why is ASPNETDB.mdf being created?". Since my site used a SQL database, ASPNETDB.mdf had not previously been present. But then suddenly it appeared and my entire site crashed at the hosting location. It was a little insidious because everything worked fine in the development environment.

In my case I wanted to get a list of user roles and I had added < roleManager enabled="true" /> in web.config. I didn't connect at the time that this would create ASPNETDB.mdf. This SO post The Role Manager feature has not been enabled has some good discussion regarding this topic.

But the point is that when I enabled the role manager, the MVC framework automatically created ASPNETDB.mdf, causing my problems at the hosting location. I found a different way to get the roles without activating the default role manager and my immediate problem was resolved.

I just wanted to add this post in the event someone else was surprised by the sudden appearance of ASPNETDB.mdf. This is another way it can show up, which is related to the op's question.

Alan
  • 1,587
  • 3
  • 23
  • 43
0

If the ASPNETDB.mdf is not needed by your application, then you can simply remove it from the "App_Data" folder where this database file is probably located and also remove the line in the web.config file that references to it.

However, this database is needed if you are using membership services as this is the place where all this information will be stored - as it was mentioned in David's answer.

Are you using one of the ASP.NET toolkits for this application? please provide more details in order to help you better.

Ricardo Sanchez
  • 6,079
  • 3
  • 24
  • 31
  • 4
    I've tried removing the database from the folder, but it is auto generated when I build the solution. There is no direct reference to ASPNETDB.mdf – Eric Oct 07 '09 at 20:48
0

The 'why' is here:

To get the aspnetdb.mdf created on the fly, one can simply Ctrl-F5 to run the web site or web application. Click “Log In” button to let the ASP.NET Development Server or IIS server process create the aspnetdb.mdf file for you.

But this is a little old I think and things have moved around a bit. The default connection string is now in the machine.config:

The default connection string is defined in machine.config

I find this incredibly odd and it caught me by surprise when i was iterating thru connection strings.

There is also a lot of talk on the internet that User Instance=true is now deprecated in favor of localdb, but I struggled to find an official line for that.

To make it stop, you can add a "clear" tag to connectionStrings section (I confirmed that this works):

<connectionStrings>
    <clear/>

I'm thinking of removing it from the machine.config.? Having it in there in the first place seems pretty heavy handed on MS's part.

b_levitt
  • 7,059
  • 2
  • 41
  • 56