Visual Studio 2010 ADO实体设计器中似乎存在一个错误,导致生成不正确的SQL。
与2010年相比:
-- Creating foreign key on [Id] in table 'BaseEntitySet_EntityA'
ALTER TABLE [dbo].[BaseEntitySet_EntityA]
ADD CONSTRAINT [FK_EntityA_inherits_BaseEntity]
FOREIGN KEY ([Id])
REFERENCES [dbo].[BaseEntitySet]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
GO
-- Creating foreign key on [Id] in table 'BaseEntitySet_EntityB'
ALTER TABLE [dbo].[BaseEntitySet_EntityB]
ADD CONSTRAINT [FK_EntityB_inherits_BaseEntity]
FOREIGN KEY ([Id])
REFERENCES [dbo].[BaseEntitySet]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
GO
注意
删除时无操作
与2012年相比
-- Creating foreign key on [Id] in table 'BaseEntitySet_EntityA'
ALTER TABLE [BaseEntitySet_EntityA]
ADD CONSTRAINT [FK_EntityA_inherits_BaseEntity]
FOREIGN KEY ([Id])
REFERENCES [BaseEntitySet]
([Id])
ON DELETE CASCADE ON UPDATE NO ACTION;
GO
-- Creating foreign key on [Id] in table 'BaseEntitySet_EntityB'
ALTER TABLE [BaseEntitySet_EntityB]
ADD CONSTRAINT [FK_EntityB_inherits_BaseEntity]
FOREIGN KEY ([Id])
REFERENCES [BaseEntitySet]
([Id])
ON DELETE CASCADE ON UPDATE NO ACTION;
GO
注意
删除级联时
将这些更改应用到数据库后,我可以毫无问题地删除。