I've a table named EducationTypes
and an Entity named EducationType
, I renamed one of entity properties, now I'm frequently getting Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong
. How can I solve this issue?
The generated SQL Script:
EXECUTE sp_rename @objname = N'dbo.EducationTypes.nvarchar', @newname = N'EducationTypeTitle', @objtype = N'COLUMN'
I just had the same issue, also after refactoring. For me, the problem was caused by a migration that was refactored as well.
The result was that another migration could not be executed because that migration was looking for a table by searching it's old name.
Reverting the changes in the migration solved this issue.
Steer clear of reserved words or class names in your migration title.
This happened to me when I named a migration "Init" - renamed to "InitialCreate" and all worked perfectly
Just spent far too much time trying to figure out why this was happening on a production database I can only access via mylittlesql. Couldn't reproduce the problem but made this script from bits of sp_rename so when it does happen next time I can find out exactly why. Yes is overkill, but might help somebody else.
There is an issue if you ever somehow manage to get '[' or ']' into the actual column name as stored in sys.columns, (? 'nvarchar' as your column name ???? ). PARSENAME doesn't cope with []'s and returns null, so sp_rename won't work.
This will only help diagnose the issue for the 'column' case with the error code 15248 which is where I keep having this issue:
This will output some helpful messages in the Messages tab (of SSMS or whatever you are using) and the table fields in the Results tab.
Good luck.
I got this with Entity Framework 6 when trying to rename a foreign key in my migrations script using the Sql(" ... ") method. The workaround I had was to use square brackets around the name:
i.e. changing this:
...to this:
SQL Server is then able to find the foreign key.
This is because of name Conflict of Class (Model) names with other reserved or generated ones, when auto creates the tables and ... .
Considering that EF Code First creates the intervene tables to relate 2 or more tables using name of tables for derived intervene table, so when you use a class name that employs a name like the intervene tables, we'll get such this ambiguous error.
For example if you have a Question class which has an Answer navigation property the internal model metadata will contain a reference called QUESTION_ANSWER
To solve this, try to change the class names (used for generating tables) and ensure their uniqueness.
Actually this error also happens when you just deleted the database, and your context does not realize that your database is not there.
I recreated the database, and now the error was resolved.
P.S. make sure you check database is still there when you try to run the update-database