1
votes

I have some stored procedure files in my database project, Visual Studio 2013. When I have a stored procedure using the CREATE PROCEDURE syntax VS underlines CREATE in red and gives this error:

The model already has an element that has the same name

When I use ALTER PROCEDURE it underlines ALTER and gives this error:

This statement is not recognized in this context

I have set the connection to my local DB server and the correct DB in which the stored procedures exist using right click/connection.

The DB project was created from scratch and not upgraded. The connection is also set correctly when checking the DB project's properties, Debug tab, target connection string.

What do I need to do so that I get neither error?

1
Can you check this postArulkumar
None of that helped. I also have some case mismatch warnings but I changed the code to be the correct case. However, because the build fails due to my reported errors, the model.sql file is not rebuilt. These casing errors are clearly using the old code.Brian Leeming
Are you using the syntax "ALTER procedure [dbo].YourProcedure"? Have you tried copying the text and opening a new window and trying again?Gaspa79

1 Answers

0
votes

My solution also contains an entity framework model and also files relating to a dacpac that I created. In the dacpac folder were 2 files: model.xml and model.sql. Looking at these files, they appeared to contain outdated t-sql code. I deleted both files, cleaned the solution and the errors associated with the keyword CREATE disappeared.

The model.xml and model.sql files were unpacked from the dacpac that I created and were a copy of the DB schema that existed when I created the dacpac. If you want to store these files in source control and make them part of the DB project, set their build action to NONE.

The correct word to use in the stored procedures is CREATE and not ALTER.