SQL Server Migrations: RenameIndex generates bad SQL when table unspecified #5520
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
MigrationBuilder.RenameIndex(...) has an optional parameter "table". When this parameter is not provided rename/migration fails
Steps to reproduce
add this to any migration
migrationBuilder.RenameIndex("existingIndex", "newIndexName");
The issue
The migration is executed and fails with
Exception message:
System.Data.SqlClient.SqlException (0x80131904): Either the parameter @objname is ambiguous or the claimed @objtype (INDEX) is wrong.
Stack:
Further technical details
The generated SQL looks like this:
EXEC sp_rename N'.existingIndex', N'newIndexName', N'INDEX';
- note the dot in first parameterRename SQL is generated here: https://github.com/aspnet/EntityFramework/blob/d5f39e3532c352c227a80ca40237a9121f17dc6e/src/Microsoft.EntityFrameworkCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs#L113
RenameIndex method should have non-optional table parameter or there should be a check for non-empty string in the linked method to provide better logging.
EF Core version: 1.0.0-rc2-final
EF Core tools version: 1.0.0-preview1-final
Operating system: Win X
DB: SQL 12.0.2000
Visual Studio version: dotnet-cli
The text was updated successfully, but these errors were encountered: