简体   繁体   English

目标框架更改4.0到3.5打破EF模型。 错误111:参照约束错误

[英]Target Framework change 4.0 to 3.5 breaks EF model. Error 111: Referential constraint errors

I created a EF model in a library project which targets .NET framework 4.0. 我在一个面向.NET framework 4.0的库项目中创建了一个EF模型。 I just downgraded it to target framework 3.5 instead since one of the projects that will be using this library targets 3.5 and cannot be upgraded at the moment. 我只是将它降级为目标框架3.5,因为其中一个将使用此库的项目目标是3.5,目前无法升级。

After changing the target framework from 4 to 3.5, I am getting multiple 111 errors similar to: 将目标框架从4更改为3.5后,我得到多个111错误,类似于:

Error 111: Properties referred by the Dependent Role WfInstance must be a subset of the key of the EntityType xx.Entity.WfInstance referred to by the Dependent Role in the referential constraint for Relationship xx.Entity.FK_WfInstance_WfStatusType. 错误111:从属角色WfInstance引用的属性必须是关系xx.Entity.FK_WfInstance_WfStatusType的引用约束中的从属角色引用的EntityType xx.Entity.WfInstance的键的子集。

What I get out of the message is that my table's (WfInstance) primary key must use/contain the Id of the referenced table (WfStatusType) and any other tables it references. 我得到的消息是我的表(WfInstance)主键必须使用/包含引用表(WfStatusType)的Id和它引用的任何其他表。 However, I am not sure how to do this. 但是,我不知道该怎么做。

Any help would be appreciated. 任何帮助,将不胜感激。

TIA - GP TIA - GP

I think you have checked (or left checked) Include foreign keys in the model when you used wizard to create model for .NET 4.0 library. 当您使用向导为.NET 4.0库创建模型时,我认为您已检查(或保留选中) 在模型中包含外键 This is a new feature in .NET 4.0 and it cannot be downgraded to .NET 3.5. 这是.NET 4.0中的一项新功能,无法降级到.NET 3.5。 You will find it easily because your entities will contain properties for foreign key columns. 您会很容易找到它,因为您的实体将包含外键列的属性。 There are some other features which can break downgrading. 还有一些其他功能可以打破降级。 Anyway believe me if you need model for .NET 3.5 the best way is deleting your EDMX and start from scratch because manually repairing broken model will be damn bad and long task. 无论如何,相信我,如果你需要.NET 3.5的模型,最好的方法是删除你的EDMX并从头开始,因为手动修复破碎的模型将是糟糕的糟糕和长期的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM