0
Good morning,
I am experiencing a problem in the Homolog version of the project
The index 'IX_ReqCompraId_Id' is dependent on column 'ReqCompraId'.
The object 'FK_dbo.Pedidos_dbo.ReqCompra_ReqCompraId' is dependent on column 'ReqCompraId'.
The object 'FK_dbo.Pedidos_dbo.ItemRC_ReqCompraId_Id' is dependent on column 'ReqCompraId'.
ALTER TABLE DROP COLUMN ReqCompraId failed because one or more objects access this column.
I have tried to make the following commands to rename Id2 to id but remains unsuccessful
ALTER TABLE [dbo].[Pedidos] DROP CONSTRAINT [PK_dbo.Pedidos]
GO
EXECUTE sp_rename @objname = N'dbo.Pedidos.Id2', @newname = N'Id', @objtype = N'COLUMN'
ALTER TABLE [dbo].[Pedidos] ADD CONSTRAINT [PK_dbo.Pedidos] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ReqCompraId_Id] ON [dbo].[Pedidos]
(
[ReqCompraId] ASC,
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
To delete the column first you need to remove dependencies. The message is very clear, you need to delete the index Ix_reqcompraid_id, as constraints by the name probably in the tables Buyout and Itemrc
– Ricardo Pontual
But this error occurs when I try to run the application
– gabrielfalieri
But at the end of the error message has "ALTER TABLE DROP COLUMN Reqcompraid failed because one or more Objects access this column.", that is, the error happened because of a DROP COLOMN
– Ricardo Pontual
Your application using some ORM as Entity Framework or Hibernate?
– Ricardo Pontual
I’m using Entity @Ricardopunctual
– gabrielfalieri
I get it, it makes sense. Probably the column was deleted from the model, when the Entity is trying to synchronize with the database, is giving this error while running the application
– Ricardo Pontual
It was deleted where you speak, no sql?
– gabrielfalieri
Let’s go continue this discussion in chat.
– gabrielfalieri