代码优先TPC - 基本表生成虽然它从不包含数据 [英] Code First TPC - Base Table Is Generated Though It Never Contains Data

查看:39
本文介绍了代码优先TPC - 基本表生成虽然它从不包含数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循下面列出的Code First Tutorial:http://weblogs.asp.net/manavi/archive/2011/01/03/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5 -part-3-table-per-concrete-type-tpc-and-chosen-strategy-guidelines.aspx教程
使用名为BillingDetails的基类和两个子类CreditCards和BankAccounts。继承和保存数据工作正常。但是生成了3个表,每个表一个。正如所料,基类BillingDetails不包含任何数据。据我了解,
永远不会。代码是否有问题,或者TPC需要这个空表吗?如果这个表可以删除,有人可以告诉我怎么样?

解决方案

确切地说,我认为这是有道理的。一开始我们不能实例化一个抽象类,但是我们可以为子类实现它。


谢谢,


Werewolf,


I am following the Code First Tutorial listed below: http://weblogs.asp.net/manavi/archive/2011/01/03/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-3-table-per-concrete-type-tpc-and-choosing-strategy-guidelines.aspx The tutorial uses a base class named BillingDetails and two subclasses CreditCards and BankAccounts. Inheritance and saving data work fine. But 3 tables were generated, one for each class. As expected, the base class, BillingDetails, contains no data. As I understand it, never will. Is there a problem with the code, or is this empty table required for TPC to work? If this table can be removed, could someone please tell me how?

解决方案

Exactly, i think it makes sense. At very first we cannot instantiate an abstract class, but we can do it for the subclass.

Thanks,

Werewolf,


这篇关于代码优先TPC - 基本表生成虽然它从不包含数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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