VSTS issues adding a new SQL Database (MDF file) for web testing

I had an interesting problem yesterday while working on creating some coded data driven web tests in VSTS. My developer PC has SQL Server 2005 installed and Visual Studio Team Suite. I was considering creating the test data in my local SQL Server database but then figured it would make more sense to create an MDF file inside the project. This would allow the database to be easily versioned in TFS (data is read only) and allow others in the team to easily run the data driven web tests as well without needing to run SQL scripts on their PC to create the tables and populate them with the sample data.

When I attempted to add the MDF file by right clicking in the project, Add | New Item.. | SQL Database, I received the following message;

“Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL:
http://go.microsoft.com/fwlink/?linkId=49251

I dutifully installed SQL Server 2005 Express edition and applied service pack 1 to it for good measure. When I tried to add the SQL Database item to the project I again received the same error message.

It is at this point that I remind readers that I am certainly no SQL expert and in fact I’m not over savvy in all things SQL at all [:$]

The fix I found was to go VS2005 into “Tools | Options | Database Tools | Data Connections” and in the Connection Options there’s a textbox labeled “SQL Server Instance Name (blank for default):”. When I entered SQLEXPRESS into this field, I was able to then start adding MDF files to my project.

I have not managed to find very much information on this and cannot guarantee this will not break anything else but in the mean time I am happily data driving my web tests and things are all OK.

Can anyone provide an insight into exactly what this field does in VS2005? Any know problems having SQL Express and SQL Server 2005 on the same box?

[UPDATE]

Peter Jones (
http://www.jonesie.net.nz
) provided the following information in answer to my questions above. He also pointed out that my blog’s “comments” feature is broken still [:@]. Looks like I might need to upgrade to the latest CS version…

Here’s Peter’s helpful response;

You can install multiple instances of SQL Server (2k, 05, Express or otherwise) on the same machine.  Each instance has a name that is specified during install.  You can also have 1 default instance.

By default, VS installs SQL Express with an instance called SQLEXPRESS.  For the database connection thing to work in VS it needs to know the name of the instance.  From the server explorer you can create a connection to any database and you get the oppurtunity to specify the server name and instance.

I’m guessing it was blank in your setup becuase you explicity chose not to install SQL Express when you installed VS.

About these ads

About anthonyborton

Anthony Borton is a Microsoft MVP in Visual Studio ALM. He is the principle ALM Consultant/Trainer at Enhance ALM, based in Brisbane, Australia.
This entry was posted in General. Bookmark the permalink.

5 Responses to VSTS issues adding a new SQL Database (MDF file) for web testing

  1. Anthony says:

    Looks like the upgrade to CS 2.0 has meant the comments are now fixed on the blog :)

  2. Rita.G says:

    That’s the same problem I have.

    I choose not to install SQL Express when I installed VS. How did you fix it then, Anthony?

  3. hahaha says:

    What if I don’t want to install express. Why in the world I need express when I have full SQL Server version running on my machine? It perfectly attaches database files from SQL Studio, why VS needs SQL Express, is it hardcoded somewhere within VS?

  4. AnthonyB says:

    Rita G.
    If you want to be able to do as I have done and add MDF files to your project, you should use Add/Remove Programs from your control panel and select Visual Studio 2005. In maintenance mode, you’ll be able to add SQL Express.
    —–
    hahaha
    As I stated, I’m not much of a SQL person so if there is a better way to do this please explain further. As I stated in this post, I wanted to be able to include the MDF file inside the project so that when others in the team checked the project out, they could run the tests using the MDF. I figured this was much more transportable. If you have a workgroup SQL server you could easily centralise the test data and point to that SQL box, but that was not my requirement.
    Cheers
    Anthony

  5. HL says:

    I guess hahaha meant that he wants to use full version of SQL Server instead of Express for the same purpose that is already installed locally. He doesn’t want to install Express in addition, but VS doesn’t allow to use full version, producing the same message. I have the same situation: SQL Server Developer’s Edition, default instance (name of the instance in options is clear, as required for default instance), but VS says it wants Express. Maybe I’m to stupid to use it properly, but I haven’t found a nice and clear solution for this issue.

Comments are closed.