Asp.net core mvc code first approach migration issues & fixes| failed executing DbCommand| LTER TABLE DROP COLUMN failed | Cannot find the object âtablenameâ because it does not exist

Failed executing DbCommand (68ms) [Parameters=[], CommandType=âTextâ, CommandTimeout=â30â]
DECLARE @var0 sysname;
SELECT @var0 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[tblOrders]â) AND [c].[name] = NâIdâ);
IF @var0 IS NOT NULL EXEC(NâALTER TABLE [tblOrders] DROP CONSTRAINT [â + @var0 + â];â);
ALTER TABLE [tblOrders] DROP COLUMN [Id];
Microsoft.Data.SqlClient.SqlException (0x80131904): ALTER TABLE DROP COLUMN failed because column âIdâ does not exist in table âtblOrdersâ.
ALTER TABLE DROP COLUMN failed because column âIdâ does not exist in table âtblOrdersâ.
Save Time, Avoid Errors & Ensure Smooth Database Deployments
Solutions:
Generally, these issues coming on code first migration when you are not defining the relations and later modify it and run migration alteration do not happen.
Steps to solve this kind of issue on DB migrations:
