Error: Cannot load file or assembly "Microsoft.SqlServer.Management.SqlParser"
Scenario: Adding a new SQL Server 2008 Database Project in Visual Studio 2010
I wanted to share the issue I found today while trying to create a SQL Server 2008 Database project in Visual Studio 2010. I have an existing database project in SQL Server 2008 and I wanted to include the database project in Visual Studio 2010 for Source Control Reasons. If you want to create a SQL Server 2008 DB Project you need to follow these steps:
1 - Right click on the Solution or Solution Folder where you want your db project to be created.
2 - From the project templates dialog box, go to the Database Node and select the template you want.
You can also find a step by step tutorial on how to create a new DB projects in Visual Studio 2010 here or how to include a existing DB in Visual Studio here.
Now the issue was that when I selected the SQL Server 2008 Database project, Visual Studio game me an error saying that "Could not load file or assembly Microsoft.SqlServer.Management.SqlParser, Version=10.0.0.0...blah blah blah"
This seemed quite estrange since I had SQL Server 2008 with SQL Management Studio and Visual Studio 2010 working just find for all the other tasks I was working on. Doing a little online research the first thing I realized was that getting the right answer for this error was very difficult. Most forums and articles I found suggested that I needed to reinstall Microsoft SQL Server 2008 Management Objects (SMO) components, or reinstall Visual Studio, which I wanted to avoid. I tried to download and install SMO components individually but it didn't work. At last my colleague Herberth Madrigal shared this link on how to install individual Visual Studio components.
Basically I had to first mount my image of the Visual Studio installer and then find the individual installers directories. Most of them are under the "WCU" folder. Then I had to install the following individual components: