views:

1093

answers:

2

I can't connect to the ASPNETDB.MDF file in the App_Data that is created by the ASP.NET MVC Beta project from Visual Studio 2008 or SQL Management Studio 2008 Express on Vista. The project is in C:\Users\Matthew\Documents\Visual Studio 2008\Projects\MVCTest so the MDF file is in C:\Users\Matthew\Documents\Visual Studio 2008\Projects\MVCTest\MVCTest\App_Data.

When I try and connect to the database in the Visual Studio 2008 Server Explorer I get the following error message.

An attempt to attach an auto-named database for file C:\Users\Matthew\Documents\Visual Studio 2008\Projects\MVCTest\App_Data\ASPNETDB.MDF failed. A databse with the same name exists, or specified file cannot be opened, or it is located on UNC share.

A: 

First, check to see if you actually have another one attached to your sqlexpress instance. If you dont, go to the file, right-click, go to properties, then security, and check out what the permissions look like. If your user doesn't have read access, that would probably be the problem.

Matt Briggs
I deleted the ASPNETDB database and recreated it with a different name by specifying it in the web.config connection string and I still get the same error.
MHinton
+1  A: 

I am chalking this down to something weird with Vista. Instead of having asp.net create the Forms auth database automatically I ran aspnet_regsql -W and created the Forms auth database in my SQLEXPRESS 2008 instance. I can attach to that once in Visual Studio 2008 and Sql Management Studio Express 2008 without any problem.

MHinton