TPH继承问题 [英] TPH Inheritance problem

查看:130
本文介绍了TPH继承问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:

DB-Table:

CREATE TABLE [base]。[AppointmentResource]

Id int Identity(1,1)NOT NULL,
IsDeleted bit,
DBTimestamp timestamp NOT NULL,
FKAppointmentId int NOT NULL,

CREATE TABLE [base].[AppointmentResource]
(
 Id int Identity(1,1) NOT NULL,
 IsDeleted bit,
 DBTimestamp timestamp NOT NULL,
 FKAppointmentId int NOT NULL,

FKLocationId int NULL,
FKProductId int NULL,
FKLogOnUserId int NULL,
FKPatientId int NULL
);

 FKLocationId int NULL,
 FKProductId int NULL,
 FKLogOnUserId int NULL,
 FKPatientId int NULL
);

我创建了4个实体,其基类是AppointmentResource,我将每个FK移动到其中一个(FKAppointmentId除外,它链接到约会本身)。所以我有4个新实体:AppLocation,AppProduct,AppLogOnUser和AppPatient。这些新实体没有字段,只有"导航属性"。各自的详细信息表。

I created 4 entities which's base-class is AppointmentResource and I moved each FK to one of them (except FKAppointmentId, which links to the appointment itself). So I have 4 new entities: AppLocation, AppProduct, AppLogOnUser and AppPatient. These new entities have no fields, just the "navigation property" to their respective detail-table.

设计人员不会验证模型并说明:

The designer won't validate the model and states:

错误1错误3022:从第1876行开始映射片段中的问题:必须映射具有'IsNull = false'条件的属性AppointmentResource.FKLocationId。

Error 1 Error 3022: Problem in Mapping Fragment starting at line 1876: Property AppointmentResource.FKLocationId with 'IsNull=false' condition must be mapped.

C:\DEV\TFS \Source1 \Synergy\DEV \ SERVER \ServicesHost \Synergy.edmx 1877 15 ServicesHost
错误2错误3022:从第1884行开始映射片段中的问题:必须映射具有'IsNull = false'条件的属性AppointmentResource.FKPatientId。

 C:\DEV\TFS\Source1\Synergy\DEV\SERVER\ServicesHost\Synergy.edmx 1877 15 ServicesHost
Error 2 Error 3022: Problem in Mapping Fragment starting at line 1884: Property AppointmentResource.FKPatientId with 'IsNull=false' condition must be mapped.

C:\DEV \ TFS \Source1 \Synergy\DEV \ SERVER \ ServicesSost\Synergy.edmx 1885 15 ServicesHost
错误3错误3022:从第1891行开始映射片段中的问题:必须映射具有'IsNull = false'条件的属性AppointmentResource.FKProductId。

 C:\DEV\TFS\Source1\Synergy\DEV\SERVER\ServicesHost\Synergy.edmx 1885 15 ServicesHost
Error 3 Error 3022: Problem in Mapping Fragment starting at line 1891: Property AppointmentResource.FKProductId with 'IsNull=false' condition must be mapped.

C:\DEV \\ TFS \Source1 \Synergy\DEV \ SERVER \ServicesHost \Synergy.edmx 1892 15 ServicesHost
错误4错误3022:从第1898行开始映射片段中的问题:属性AppointmentResource.FKLogOnUserId with'IsNull =必须映射false'条件。

 C:\DEV\TFS\Source1\Synergy\DEV\SERVER\ServicesHost\Synergy.edmx 1892 15 ServicesHost
Error 4 Error 3022: Problem in Mapping Fragment starting at line 1898: Property AppointmentResource.FKLogOnUserId with 'IsNull=false' condition must be mapped.

C:\DEV \ TFS \Source1 \Synergy\DEV \ SERVER \ Serviceshost \Synergy.edmx 1899 15 ServicesHost

 C:\DEV\TFS\Source1\Synergy\DEV\SERVER\ServicesHost\Synergy.edmx 1899 15 ServicesHost

courese它们没有被映射,因为映射是在关系中定义的,而不是表格!

Of courese they aren't mapped, because the mapping is defined in the relation, not the table!

任何人都有建议如何绕过这个错误?

Anyone have a suggestion of how to circumvent this error?

推荐答案

根据博客我发现这是一个错误?! http://msmvps.com/blogs/matthieu/archive/2008/08/23 /tph-limitation-which-should-disappear-with-v2.aspx

请告诉我有一个解决方法!我无法相信EF团队错过了这一点......

Please tell me there is a workaround! I can't believe this was missed by the EF-team...


这篇关于TPH继承问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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