I think this falls into the category of 'never ask a developer to do a server administrator's job'.

I'm a developer writing a couple of ASP.NET MVC 2 sites. I've attempted to use the ASP.NET Configuration Tool to create some user roles, but it keeps giving me an error stating that it can't find my data store, and that the AspNetSqlProvider cannot connect to the db. I have run aspnet_regsql, but that only created the tables necessary for user management. It did nothing to help my connection problem. From what I can see, my connection strings are okay.

As a test, I fired up some MVC tutorial apps in the debugger. Both displayed and saved my inputed data, so it seems like the database is working to some extent.

Following that, I decided to test if I could attach some .mdf files to the db via the Management Studio. I tried both an 'empty' file (folder structure intact, but no tables) and one that I've fleshed out for one of my projects. In both cases, the Management Studio claimed it couldn't find the files, despite both existing and me manually entering their paths.

All of this seems to point to a permissions issue. I'm just not sure on which side the problem resides - db or files - or how to fix it. Any help would be greatly appreciated.

Note: all of this is happening on my Win 7 laptop, with Visual Studio 2010 Professional.

  • It is not permission issue, it is peculiarities of working with db through VS(Server Explorer) and SSMS. Use only one of them, you can't use both – Gennady Vanin Геннадий Ванин Aug 28 '10 at 5:21

When you say "attach some .mdf files to the db" I'm going to assume you mean to the SQL instance. You don't really attach .mdf files to an existing db.

A couple of things to check:

  • What version of SQL were the .mdf files created with? If it's 2008 R2 then you won't be able to attach them to a straight-up 2008 instance, they're not backward compatible.
  • Are you also bringing the log file(s) over when you try to attach the .mdf files? Depending on what recovery model the databases were create with you'll also need those. By default SQL will create a database and set it to the full recovery model in which case it needs the log file(s) in order to get the database back to its current state.
  • The .mdf files were created within VS 2010. AFAIK, the laptop is only running the version of SQL Server 2008 that comes with VS 2010 Professional. The corresponding log files were automatically added to the list of .mdf files to attach when I entered in the .mdf paths. – Major Productions Aug 27 '10 at 14:39
  • Actually, now that I'm on my laptop, I see I have both SQL Server 2008 (64-bit) AND SQL Server 2008 R2 (32-bit). Both seem to be Express. I can't tell if both, or just one is running. The management studio only shows one sqlexpress instance running. I believe my copy of VS 2010 is 32-bit, if that makes a difference. It's the version available through the Website Spark program. – Major Productions Aug 27 '10 at 16:27
  • Well, I was able to detach the role management db from the instance and add the .mdf to my project's App_Data folder, like what was done with the MVCMusicStore demo. Didn't fix my overall issue of the provider not seeing the server, but feels like some progress. – Major Productions Aug 27 '10 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.