Migrations: table rename throws an exception #24175
Labels
area-migrations
area-sqlserver
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
punted-for-6.0
type-bug
Milestone
I have created new migration which produced following code.
Table is to be renamed from
Image
toImages
.After running
update-database
, following exception was thrown:I tried to run the T-SQL on the target DB to make sure
EXEC sp_rename N'[Image]', N'Images';
Following error was reported back:
Workaround
Following T-SQL code is workaround:
EXEC sp_rename 'Database.Schema.TableName', 'NewTableName';
I have run
EXEC sp_rename 'dbo.Image', 'Images';
which successfully renamed the table.Another solution would be to manually edit migration and add explicit schema to the migration:
Provider and version information
EF Core version: 5.0.3
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5
Operating system: Windows 10
IDE: Visual Studio 2019 18.6.5
The text was updated successfully, but these errors were encountered: