随笔分类 -  EntityFramework

摘要:待补充 阅读全文
posted @ 2012-03-30 19:46 libingql 阅读(2755) 评论(1) 推荐(0) 编辑
摘要:前面几节,使用的都是通过EF Code First创建的新数据库,接下来,将开始使用已存在的数据库。 1、使用配置文件设置数据库连接 App.config 数据库连接字符串的name与Data中NorthwindContext.cs类名相同<?xml version="1.0" encoding="utf-8"?><configuration> <configSections> <!-- For more information on Entity Framework configuration, visit h 阅读全文
posted @ 2012-03-30 13:05 libingql 阅读(15332) 评论(5) 推荐(3) 编辑
摘要:EF Code First数据库映射规则主要包括以下方面:1、表名及所有者映射Data Annotation:指定表名1 using System.ComponentModel.DataAnnotations;2 3 [Table("Product")]4 public class Product指定表名及用户using System.ComponentModel.DataAnnotations;[Table("Product", Schema = "dbo")]public class ProductFluent API:指定表名1 阅读全文
posted @ 2012-03-29 23:21 libingql 阅读(5660) 评论(2) 推荐(3) 编辑
摘要:1、一对多关系关系表:Category 分类表Product 产品表分类与产品之间的一对多关系1>、产品实体类不指定外键属性Domain中类定义:Category.cs 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 using System.ComponentModel.DataAnnotations; 7 8 namespace Northwind.Domain.Entities 9 {10 public class Categor... 阅读全文
posted @ 2012-03-28 13:09 libingql 阅读(9758) 评论(5) 推荐(7) 编辑