摘要: 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) 编辑
摘要: 延迟加载:延迟加载相关的数据 首先查询Student表 再查询StudentAddress表 可以为指定的属性或整个上下文关闭延迟加载的功能,关闭属性的延迟加载功能就是不要设置属性为virtual 延迟加载的规则: 1.context.Configuration.ProxyCreationEnabl 阅读全文
posted @ 2017-03-26 16:01 蓝平凡 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 延迟加载:延迟加载相关的数据 首先查询Student表 再查询StudentAddress表 可以为指定的属性或整个上下文关闭延迟加载的功能,关闭属性的延迟加载功能就是不要设置属性为virtual 延迟加载的规则: 1.context.Configuration.ProxyCreationEnabl 阅读全文
posted @ 2017-03-26 15:59 蓝平凡 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 贪婪加载是指查询一个类型实体的时候同时查询与实体关联的类型 通过Include()方法实现 Load multiple levels of related entities: 阅读全文
posted @ 2017-03-26 15:53 蓝平凡 阅读(434) 评论(0) 推荐(0) 编辑
摘要: DBSet的Local属性提供简单的从context上下文获取当前已经被跟踪的实体(实体不能被标记为Deleted状态) 上面的例子中表明,本地数据保持跟踪状态为Added,Modified,Unchanged状态的实体 DBSet集合跟踪状态为Deleted,Modified,Unchanged实 阅读全文
posted @ 2017-03-26 15:26 蓝平凡 阅读(479) 评论(0) 推荐(0) 编辑
摘要: USE [SchoolDB] GO /****** Object: UserDefinedFunction [dbo].[GetCourseListByStudentID] */ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[GetCo... 阅读全文
posted @ 2017-03-26 15:02 蓝平凡 阅读(310) 评论(0) 推荐(0) 编辑
摘要: MS SQl Server引进两种特殊的数据类型geography and geometry 阅读全文
posted @ 2017-03-26 14:53 蓝平凡 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 1. Convert an existing property to Enum: 2. Add New Enum from Designer: 3. If you already have Enum type created in your code, then you can use that a 阅读全文
posted @ 2017-03-26 12:54 蓝平凡 阅读(288) 评论(0) 推荐(0) 编辑
摘要: To migrate your existing Entity Framework 4.x project to Entity Framework 5.0 using VS2012, first target .NET Framework 4.5: Second, remove the existi 阅读全文
posted @ 2017-03-26 12:43 蓝平凡 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 我们先创建如下3个存储过程 1.Sp_InsertStudentInfo: 2.sp_UpdateStudent: 3.sp_DeleteStudent 将存储过程添加到EDM中 实体浏览器将存储过程添加到存储模型中,但是不引进函数 在EDM设计器中,右键Student实体,选择存储过程映射 上面代 阅读全文
posted @ 2017-03-26 12:39 蓝平凡 阅读(302) 评论(0) 推荐(0) 编辑