7.翻译系列:EF 6中的继承策略(EF 6 Code-First 系列)
原文地址:http://www.entityframeworktutorial.net/code-first/inheritance-strategy-in-code-first.aspx
EF 6 Code-First系列文章目录:
- 1 翻译系列:什么是Code First(EF 6 Code First 系列)
 - 2.翻译系列:为EF Code-First设置开发环境(EF 6 Code-First系列)
 - 3.翻译系列:EF Code-First 示例(EF 6 Code-First系列)
 - 4.翻译系列:EF 6 Code-First默认约定(EF 6 Code-First系列)
 - 5.翻译系列:EF 6中数据库的初始化(EF 6 Code-First 系列)
 - 6.翻译系列:EF 6 Code-First中数据库初始化策略(EF 6 Code-First系列
 - 7.翻译系列:EF 6中的继承策略(EF 6 Code-First 系列)
 - 8.翻译系列: EF 6中配置领域类(EF 6 Code-First 系列)
 - 9.翻译系列:EF 6以及EF Core中的数据注解特性(EF 6 Code-First系列)
 - 9.1 翻译系列:数据注解特性之----Table【EF 6 Code-First 系列】
 - 9.2 翻译系列:数据注解特性之---Column【EF 6 Code First系列】
 - 9.3 翻译系列:数据注解特性之Key【EF 6 Code-First 系列】
 - 9.4 翻译系列:EF 6以及 EF Core中的NotMapped特性(EF 6 Code-First系列)
 - 9.5 翻译系列:数据注解之ForeignKey特性【EF 6 Code-First系列】
 - 9.6 翻译系列:数据注解之Index特性【EF 6 Code-First系列】
 - 9.7 翻译系列:EF数据注解特性之--InverseProperty【EF 6 Code-First系列】
 - 9.8 翻译系列:数据注解特性之--Required 【EF 6 Code-First系列】
 - 9.9 翻译系列:数据注解特性之--MaxLength 【EF 6 Code-First系列】
 - 9.10 翻译系列:EF数据注解特性之StringLength【EF 6 Code-First系列】
 - 9.11 翻译系列:数据注解特性之--Timestamp【EF 6 Code-First系列】
 - 9.12 翻译系列:数据注解特性之ConcurrencyCheck【EF 6 Code-First系列】
 - 10.翻译系列:EF 6中的Fluent API配置【EF 6 Code-First系列】
 - 10.1.翻译系列:EF 6中的实体映射【EF 6 Code-First系列】
 - 10.2.翻译系列:使用Fluent API进行属性映射【EF 6 Code-First】
 - 11.翻译系列:在EF 6中配置一对零或者一对一的关系【EF 6 Code-First系列】
 - 12.翻译系列:EF 6 中配置一对多的关系【EF 6 Code-First系列】
 - 13.翻译系列:Code-First方式配置多对多关系【EF 6 Code-First系列】
 - 14.翻译系列:从已经存在的数据库中生成上下文类和实体类【EF 6 Code-First系列】
 - 15.翻译系列:EF 6中的级联删除【EF 6 Code-First 系列】
 - 16.翻译系列:EF 6 Code -First中使用存储过程【EF 6 Code-First系列】
 - 17.翻译系列:将Fluent API的配置迁移到单独的类中【EF 6 Code-First系列】
 - 18.翻译系列:EF 6 Code-First 中的Seed Data(种子数据或原始测试数据)【EF 6 Code-First系列】
 - 19.翻译系列:EF 6中定义自定义的约定【EF 6 Code-First约定】
 - 20.翻译系列:Code-First中的数据库迁移技术【EF 6 Code-First系列】
 - 20.1翻译系列:EF 6中自动数据迁移技术【EF 6 Code-First系列】
 - 20.2.翻译系列:EF 6中基于代码的数据库迁移技术【EF 6 Code-First系列】
 - 21.翻译系列:Entity Framework 6 Power Tools【EF 6 Code-First系列】
 
我们已经在Code-First 默认约定中学习到,EF将会为每一个具体的领域类创建数据库表。然而,你可以使用继承来设计你的领域类。面向对象技术包含一个has a和 is a的关系,然而基于SQL的关系模型,在数据表之间只有 has a关系。SQL 数据库管理系统不支持类型的继承,那么怎么来映射面向对象设计的领域类和关系型数据库呢?
在Code-First模式中,有3种不同的方法,来实现继承层级关系。
- Table per Hierarchy (TPH):这种方法建议是为整个类的继承层级,创建一个表。【例如Student实体,继承了BaseEntity实体(包含3个属性:ID、AddedDate、ModifiedDate),那么到时候就还是生成一个Students表,只不过Students表里面包含BaseEntity实体的这三个属性列】。这个方法创建的表,包含一个鉴定列,可以区分类之间的继承关系。这个方法也是EF中默认的继承映射策略。
 - Table per Type (TPT):这种方法,建议为每个单独的领域类,创建一个单独的数据库表。
 - Table per Concrete Class (TPC):这个方法建议为每一个具体的类,创建一个数据库表,但是抽象类除外。所以,如果你在多个具体的类中继承了抽象类,那么抽象类的属性就会在每个具体类所生成的数据表中。
 
这里我们不会详细介绍这三种方法。想要了解更多详细细节,请访问下面的三个链接:
- Inheritance with EF Code First: Table per Hierarchy (TPH)
 - Inheritance with EF Code First: Table per Type (TPT)
 - Inheritance with EF Code First: Table per Concrete class (TPC)
 
大家请注意:这三篇文章,我后面会翻译。谢谢大家支持。
7.翻译系列:EF 6中的继承策略(EF 6 Code-First 系列)的更多相关文章
- EF CodeFirst系列(3)---EF中的继承策略(暂存)
		
我们初始化数据库一节已经知道:EF为每一个具体的类生成了数据库的表.现在有了一个问题:我们在设计领域类时经常用到继承,这能让我们的代码更简洁且容易管理,在面向对象中有“has a”和“is a”关系 ...
 - 20.2.翻译系列:EF 6中基于代码的数据库迁移技术【EF 6 Code-First系列】
		
原文链接:https://www.entityframeworktutorial.net/code-first/code-based-migration-in-code-first.aspx EF 6 ...
 - 20.1翻译系列:EF 6中自动数据迁移技术【EF 6 Code-First系列】
		
原文链接:https://www.entityframeworktutorial.net/code-first/automated-migration-in-code-first.aspx EF 6 ...
 - 20.翻译系列:Code-First中的数据库迁移技术【EF 6 Code-First系列】
		
原文链接:https://www.entityframeworktutorial.net/code-first/migration-in-code-first.aspx EF 6 Code-First ...
 - 19.翻译系列:EF 6中定义自定义的约定【EF 6 Code-First约定】
		
原文链接:https://www.entityframeworktutorial.net/entityframework6/custom-conventions-codefirst.aspx EF 6 ...
 - 16.翻译系列:EF 6 Code -First中使用存储过程【EF 6 Code-First系列】
		
原文链接:https://www.entityframeworktutorial.net/entityframework6/code-first-insert-update-delete-stored ...
 - 15.翻译系列:EF 6中的级联删除【EF 6 Code-First 系列】
		
原文链接:https://www.entityframeworktutorial.net/code-first/cascade-delete-in-code-first.aspx EF 6 Code- ...
 - 11.翻译系列:在EF 6中配置一对零或者一对一的关系【EF 6 Code-First系列】
		
原文链接:https://www.entityframeworktutorial.net/code-first/configure-one-to-one-relationship-in-code-fi ...
 - 5.翻译系列:EF 6中数据库的初始化(EF 6 Code-First 系列)
		
原文地址:http://www.entityframeworktutorial.net/code-first/database-initialization-in-code-first.aspx EF ...
 
随机推荐
- SpringMVC异常处理注解@ExceptionHandler@ControllerAdvice@ResponseStatus
			
参考: http://blog.csdn.net/w372426096/article/details/78429132 http://blog.csdn.net/w372426096/article ...
 - 【AtCoder】ARC081
			
C - Make a Rectangle 每次取两个相同的且最大的边,取两次即可 #include <bits/stdc++.h> #define fi first #define se ...
 - class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
			
1.查看路径有没有写错 2.编辑器认为你的文件不是 source folders(原文件),需要你手动将文件改过来
 - zyb的面试
			
今天zyb参加一场面试,面试官听说zyb是ACMer之后立马抛出了一道算法题给zyb:有一个序列,是1到n的一种排列,排列的顺序是字典序小的在前,那么第k个数字是什么?例如n=15,k=7, 排列顺序 ...
 - 【Java】 剑指offer(19) 正则表达式匹配
			
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 请实现一个函数用来匹配包含'.'和'*'的正则表达式.模式中的字符 ...
 - HQL  count(*)
			
public int getTarPage() { String hql = "'"; Query query = getSession().creat ...
 - sleep() 和 wait() 有什么区别?
			
sleep:Thread类中定义的方法,表示线程休眠,会自动唤醒: wait:Object中定义的方法,需要手工调用notify()或者notifyAll()方法. sleep是线程类(Thread ...
 - YUI Compressor  JS和CSS压缩工具使用方式(使用前安装JDK)
			
压缩测试: 选中 test.js, 执行右键菜单“Process with &YUICompressor”,会生成 test-min.js. 注意事项: 1. 需要安装 JDK >= 1 ...
 - ps怎么撤销的三种方法和ps撤销快捷键以及连续撤销多步快捷键
			
内容提要:文章综合介绍ps撤销快捷键相关的一些操作,包括PS怎么撤销.PS撤销多步.ps连续撤销快捷键.历史记录面板操作等等. 关于ps怎么撤销操作,有多种方法:使用PS撤销快捷键.编辑菜单.文件菜单 ...
 - 机器学习笔记(2):线性回归-使用gluon
			
代码来自:https://zh.gluon.ai/chapter_supervised-learning/linear-regression-gluon.html from mxnet import ...