映射参与多个关系的外键 [英] Mapping a foreign key participating in multiple relationships

查看:117
本文介绍了映射参与多个关系的外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型数据库,其中包含五个表的子集:
一个 http://www.senselessdestruction.com/AssociationProblem.jpg

当根据这些表创建实体模型时,我收到错误:

从存储模型中省略了外键约束'FK_UserContractCompanies_TimesheetContractEntries'。表'SMSModel.Store.UserContractCompanies'的列'CompanyId'是参与多个关系的外键。一对一的实体模型将无法验证,因为数据不一致是可能的。

预期的业务逻辑是将一部分用户作为合同用户。合同用户到达工作场所,可以登录(在TimesheetEntries表中输入一个条目),工作X小时然后退出。对于作为合同用户的任何用户,TimesheetContractEntries表用于记录分为两个记录的时间。第一条记录是显示前8.5小时工作的开始和结束时间,没有相关的ContractCompanyId,第二条记录是与相关ContractCompanyId的剩余时间。

我正在使用VS 2010 Beta 2,并尝试在模型中包含外键列。我的数据库架构是否存在缺陷或者无论如何都要克服EF中的这个限制?

I have a large database with a subset of five tables described here:

http://www.senselessdestruction.com/AssociationProblem.jpg

When creating an entity model based on those tables I get the error:

Foreign key constraint 'FK_UserContractCompanies_TimesheetContractEntries' has been omitted from the storage model. Column 'CompanyId' of table 'SMSModel.Store.UserContractCompanies' is a foreign key participating in multiple relationships. A one-to-one Entity Model will not validate since data inconsistency is possible.

The intended business logic is to have a subset of users as contract users. A contract user arrives at the workplace, can sign in (an entry is made in the TimesheetEntries table), work for X hours and then sign out. For any user that is a contract user, the TimesheetContractEntries table exists to record their times broken into two records. The first record would be start and end times showing the first 8.5 hours of work, without a related ContractCompanyId, and the second record would be the remaining time with a related ContractCompanyId.

I'm using VS 2010 Beta 2, and have tried including foreign key columns in the model. Is the schema of my database flawed or is there anyway to overcome this limitation in the EF?

-Mike.

推荐答案

Mike Mike,

由于您正在使用VS2010 Beta2,我将移动您发布此问题的EF预发布论坛, http://social.msdn.microsoft.com/Forums/en-US/adonetefx/threads

还有更多关于EF测试版的专家。

谢谢!
冯一春
Hi Mike,

Since you are working with VS2010 Beta2, I'm moving you post to EF pre-release forum for this issue,
http://social.msdn.microsoft.com/Forums/en-US/adonetefx/threads

There are more experts on the beta version of EF.


Thanks!
Yichun Feng


这篇关于映射参与多个关系的外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆