上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: 数据注解:配置选项的子集;Fluent API包含所有选项 System.ComponentModel.DataAnnotations Attributes: System.ComponentModel.DataAnnotations.Schema Attributes: AttributeDesc 阅读全文
posted @ 2017-03-28 22:55 蓝平凡 阅读(820) 评论(1) 推荐(1) 编辑
摘要: Code First中有三种不同的方法表示继承层次关系 1.Table per Hierarchy (TPH): 这种方法建议用一个表来表示整个类的继承层次关系,表中包含一个识别列来区分继承类,在EntityFramework中,这是默认的实现 类与数据库表的映射最简单的策略应该是:每个持久类对应一 阅读全文
posted @ 2017-03-28 00:53 蓝平凡 阅读(2432) 评论(0) 推荐(2) 编辑
摘要: Context类的基类构造函数有如下的参数 1.无参数 如果没有给基类构造函数添加参数,它会在local SQLEXPRESS server创建数据库,名为{Namespace}.{Context class name} 上面创建的数据库名称为:SchoolDataLayer.Context 2.参 阅读全文
posted @ 2017-03-26 23:23 蓝平凡 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 协定是一系列的默认规则用来自动配置领域中的概念模型 1:类型发现 Code-First对包含DBSet属性的类型创建表(包括这些类型的所有引用类型) 上图所示:即使上下文不包含Teacher的实体集,Code-First也为Teacher创建表 Code-First发现类型的协定: 1)上下文中的D 阅读全文
posted @ 2017-03-26 22:34 蓝平凡 阅读(729) 评论(0) 推荐(0) 编辑
摘要: 什么是Code-First 基本工作流: 写好应用程序的领域类和上下文类→配置领域类的额外映射→运行程序→Code-First API创建新的数据库或与现有数据库对应→添加种子数据到数据库中测试 阅读全文
posted @ 2017-03-26 16:40 蓝平凡 阅读(350) 评论(0) 推荐(1) 编辑
摘要: You can change the color of an entity in the designer so that it would be easy to see related groups of entities in the designer from Visual Studio 20 阅读全文
posted @ 2017-03-26 16:33 蓝平凡 阅读(273) 评论(0) 推荐(0) 编辑
摘要: Visual Studio 2012 provides a facility to split the design time visual representation of the Entity Data Model. This means that you can have multiple 阅读全文
posted @ 2017-03-26 16:32 蓝平凡 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 可以为实体实现自定义验证,重写DBContext中的个ValidateEntity方法 阅读全文
posted @ 2017-03-26 16:24 蓝平凡 阅读(795) 评论(0) 推荐(0) 编辑
摘要: SQL query for entity types: 注意:查询的字段必须和实体中的属性名对应 SQL query for non-entity types: Raw SQL commands to the database: 阅读全文
posted @ 2017-03-26 16:15 蓝平凡 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 即使延迟加载不能使用,也可以通过明确的调用来延迟加载相关实体 使用DBEntryEntity来完成 阅读全文
posted @ 2017-03-26 16:05 蓝平凡 阅读(227) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页