摘要:        
为了说明什么是复杂属性,先举一个例子。 public class CompanyAddress { public int ID { get; set; } public string CompanyName { get; set; } public string StreetAddress { get; set; } public string City { get; set; } public string State { get; set; } public string ZipCode { get;...    阅读全文
posted @ 2013-01-17 16:25
Gyoung
阅读(8433)
评论(5)
推荐(22)
        
            
        
        
摘要:        
要更改EF中的默认配置有两个方法,一个是用Data Annotations(在命名空间System.ComponentModel.DataAnnotations;),直接作用于类的属性上面;还有一个就是Fluent API,通过新增相应的配置类来覆盖默认配置。现在我们用这两个来对比了解EF中的约定配置。主键:KEYData Annotations:通过Key关键字来标识一个主键[Key]public int DestinationId { get; set; }Fluent API:public class BreakAwayContext : DbContext { pu...    阅读全文
posted @ 2013-01-17 15:12
Gyoung
阅读(43443)
评论(9)
推荐(48)
        
            
        
        
摘要:        
Code First是Entity Framework提供的一种新的编程模型。通过Code First我们可以在还没有建立数据库的情况下就开始编码,然后通过代码来生成数据库。下面通过一个简单的示例来了解。建立一个控制台项目。通过Nuget来获取Entity Framework。增加两个模型类: public class Destination { public int DestinationId { get; set; } public string Name { get; set; } public string Country { get; ...    阅读全文
posted @ 2013-01-17 09:47
Gyoung
阅读(50432)
评论(18)
推荐(42)
        

 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号