EF CTP5代码首次TPC配置是否要求基类是抽象的。 [英] Does EF CTP5 code first TPC configuration require the base class to be abstract.

查看:57
本文介绍了EF CTP5代码首次TPC配置是否要求基类是抽象的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于CTP5代码,首先TPC才能正常工作,基类必须是抽象的吗?


 


例如,我有以下实体:



公共类责任中心 


{


public int ID {get;组; }


public string Name {get;组; }


}



 


公共类CostCenter:ResponsibilityCenter


{


public string Test   {get;组; }


}


 


我正在使用EF CTP5 Code First将这些实体配置为TPC。我无法在CostCenter配置中配置ResponsibilityCenter属性。 


 


例如,在下面的配置中,Name属性我执行配置时无法识别。 


属性(p => p.Name).HasColumnName(" Description");


 


这是一个缺陷,还是需要为代码提取抽象的基类,首先是TPC允许配置基类属性?  


 


这是一个非常人为的例子。 

解决方案

我认为我的问题不够明确。我最终想要的是一个ResponsibilityCenter表和一个CostCenter表,其中CostCenter表包含ResponsibiltyCenter表的所有属性。


ResponsibilityCenter(ID,Name)


CostCenter(身份证,姓名,测试)


 


我相信以下内容:


TPH将生成一个包含两个实体的所有属性的表。 


TPT将生成一个ResponsibilityCenter表和一个CostCenter表,其中Cost Center表不具有来自ResponsibilityCenter表的非键属性(Name),表之间会有关系。


TPC会生成与TPT相同的表而没有表之间的关系。  ;


 


是否存在代码优先配置,可以在不更改实体类的情况下生成上面显示的两个表?


我想我真的很喜欢映射多个t的配置功能将层次结构中的ables转换为单个表。  


For CTP5 code first TPC to work properly, does the base class have to be abstract?

 

For example, I have the following entities:

public class ResponsibilityCenter 

{

public int ID { get; set; }

public string Name { get; set; }

}

 

public class CostCenter : ResponsibilityCenter

{

public string Test  { get; set; }

}

 

I am using EF CTP5 Code First to configure these entities as TPC. I am unable to configure the ResponsibilityCenter properties in the CostCenter configuration. 

 

For example, in the configuration below, the Name property is not recognized when I execute the configuration. 

Property(p => p.Name).HasColumnName("Description");

 

Is this a defect, or are the base class(es) required to be abstract for code first TPC to allow the base class properties to be configured?  

 

This is a very contrived example. 

解决方案

I don't think my question was clear enough. What I wanted to end up with was a ResponsibilityCenter table, and a CostCenter table where the CostCenter table includes all the properties of the ResponsibiltyCenter table.

ResponsibilityCenter (ID, Name)

CostCenter (ID, Name, Test)

 

I believe the following:

TPH would generate a single table with all the properties from both entities. 

TPT would generate a ResponsibilityCenter table and a CostCenter table where the Cost Center table would not have the non-key properties (Name) from the ResponsibilityCenter table, and there would be a relationship between the tables.

TPC would generate the same tables as TPT without the relationship between the tables. 

 

Is there a code-first configuration that would generate the two tables shown above without changing the entity classes?

I guess I would really like the configuration capability to map multiple tables in a hierarchy into a single table.  


这篇关于EF CTP5代码首次TPC配置是否要求基类是抽象的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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