CTP5 TPT映射问题:无法为类型“CategorizedItem”指定实体拆分,因为它是继承层次结构的一部分。 [英] CTP5 TPT Mapping Issue: Entity splitting cannot be specified for type 'CategorizedItem' since it is part of an inheritance hierarchy.

查看:45
本文介绍了CTP5 TPT映射问题:无法为类型“CategorizedItem”指定实体拆分,因为它是继承层次结构的一部分。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们不再能够拥有一个带有自己的表的基本抽象类吗?  每个具体类的表都需要抽象类中定义的属性列吗?


如果我的假设是错误的,请纠正我,但TPT映射的最大强度不是存储的能力一个表中的基类属性和另一个表中的继承类属性?


我还应该注意到我没有做任何明确的拆分。  我的原始CTP4映射使用以下方法映射每种类型:


MapHierarchy< BaseAbstractClass>(entity => new {base_class_id = entity.id,base_property1 = entity.Property1})。ToTable(" ; BaseTable");


MapHierarchy< InheritingClass>(entity => new {inheriting_class_id = entity.id,inheriting_property = entity.Property1})。ToTable(" InheritingTable");


这很好用。  由于CTP5的变化,我现在使用以下映射:


 


Map(mapping => mapping.Properties( entity => new {base_class_id = entity.id,base_property = entity.BaseProperty}))。ToTable(" BaseTable");


Map(mapping => mapping.Properties( entity => new {inheriting_class_id = entity.id,my_property = entity.MyProperty}))。ToTable(" InheritingTable");


 


现在我收到以下错误: 


映射问题:无法为类型'CategorizedItem'指定实体拆分,因为它是继承层次结构的一部分。


我尝试过使用Map()方法,执行Map(mapping => mapping.MapInheritedProperties());但它似乎不起作用。


我正在映射到现有数据库,这就是我们目前从表的角度来看它的方式。  非常感谢任何帮助或见解。  


编辑:


这可能是因为我是如何映射Id的吗?  具体来说,基类和继承类的主键是受约束的(因此,继承类Id是非标识的,基类是)。  继承类是否有自己的标识
列,然后是基类的外键才能使其工作?




W. Brian

解决方案

如果你真的想要映射它的样子,那么你可能面对这个

http://blog.cincura.net/232224-efv4-ctp5-some-missing-features-mapping/

Are we no longer able to have a base abstract class with its own table?  Do tables for each concrete class require columns for properties defined in the abstract class?

Correct me if my assumption was wrong, but isn't the TPT mapping's greatest strength the ability to store base class properties in one table and inheriting class properties in another?

I should also note that I'm not doing any explicit splitting.  My original CTP4 mappings mapped each type using:

MapHierarchy<BaseAbstractClass>(entity => new {base_class_id = entity.id, base_property1 = entity.Property1}).ToTable("BaseTable");

MapHierarchy<InheritingClass>(entity => new {inheriting_class_id = entity.id, inheriting_property = entity.Property1}).ToTable("InheritingTable");

This worked just fine.  Due to the changes in CTP5, I now use the following mapping:

 

Map(mapping => mapping.Properties(entity => new {base_class_id = entity.id, base_property = entity.BaseProperty})).ToTable("BaseTable");

Map(mapping => mapping.Properties(entity => new {inheriting_class_id = entity.id, my_property = entity.MyProperty})).ToTable("InheritingTable");

 

Now I get the following error: 

Mapping Issue: Entity splitting cannot be specified for type 'CategorizedItem' since it is part of an inheritance hierarchy.

I've tried playing around with the Map() method, doing things like Map(mapping => mapping.MapInheritedProperties()); but it doesn't seem to work.

I am mapping to an existing database and this is how we currently do it from a table perspective.  Any help or insights are greatly appreciated.  

Edit:

Could this be because of how I'm mapping Id's?  Specifically, the primary keys of the base class and the inheriting class are constrained (so, inheriting class Id is non-identity, base class is).  Should the inheriting classes have their own identity column and then a foreign key to the base class to make this work?


W. Brian

解决方案

If you really want to map what it looks like, then you're probably facing this http://blog.cincura.net/232224-efv4-ctp5-some-missing-features-mapping/.


这篇关于CTP5 TPT映射问题:无法为类型“CategorizedItem”指定实体拆分,因为它是继承层次结构的一部分。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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