Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLCLR database name adds _1 every time I make a change to the project

This is a new phenomenon I am seeing, my Database name is: MySQLCLR, there is a script that always give this name in it:

:setvar DatabaseName "MySQLCLR"

all of a sudden now, everytime I make any change to my sqlclr project code and re-compile, the new output script has the name with an added _1 in it, like the following:

:setvar DatabaseName "MySQLCLR_1"

Another change to the code and subsequent build will generate this:

:setvar DatabaseName "MySQLCLR_1_1"

and so forth....

any idea why this is happening?

VS2012, MSSQL2008 R2 on windows 2008 R2

like image 569
Pacman Avatar asked Jan 31 '13 17:01

Pacman


People also ask

How do I connect a database to an existing project?

In the SQL Connect window, click Create from an existing database project. The Create from an existing database project dialog box is displayed: Click Browse and specify the location of your database project or folder. For SQL Server Database Projects, this is the folder containing the project file.

What is a Dacpac file?

What is a DACPAC? A DACPAC is a data-tier application package in the form of a windows file containing all the database structure into one unit.

What is .sqlproj file?

Database development project created by Visual Studio, a Windows software development IDE; stores the schema of the database and can include SQL source code; used for creating databases for SQL Server, Microsoft's relational database management system (RDBMS) software. Older .


3 Answers

Go to your project's properties, go to Debug and under the Target Connection String section, click on Restore Default.

Maybe you'll need to install the SQL Server Data Tools - December 2012 update.

like image 85
Alex Filipovici Avatar answered Sep 29 '22 15:09

Alex Filipovici


I think it is because it saves the database at the same location without overwriting the old database, is your database connected in visual studio? if it is, try this:

Search for your database in the solution explorer example: "database.sdf". click on the database and look in the properties. There should probably be a property which is for default "don't copy" or something, change that to copy if newer and then recompile. does the problem then still exists?

like image 41
Joey De Laat Avatar answered Sep 29 '22 16:09

Joey De Laat


I have seen visual studio cause this issue with other SQL project files as well. In my case, it was because their are files already in that location with the name you are trying to give it. Check that directory and see if the files already exist. If they do, delete them and then your script should behave as expected.

I ran into this issue when people would do a bad TFS merge and left hanging generated files on their local computer. When they went to re-generate them, the generator incremented all of the file names in a similar fashion to what you are describing.

like image 33
lehn0058 Avatar answered Sep 29 '22 14:09

lehn0058