Programming EF with Code First (二) - Configuration for relationships

简介:  public class Destination{public int DestinationId { get; set; }public string Name { get; set; }public string Country { get; set; }public stri...

 

public  class Destination
{
public  int DestinationId {  getset; }
public  string Name {  getset; }
public  string Country {  getset; }
public  string Description {  getset; }
public  byte[] Photo {  getset; }
public List<Lodging> Lodgings {  getset; }
}

 

public  class Lodging
{
public  int LodgingId {  getset; }
public  string Name {  getset; }
public  string Owner {  getset; }
public  bool IsResort {  getset; }
public  decimal MilesFromNearestAirport {  getset; }
public Destination Destination {  getset; }
}

 

Specifying an optional one-to-many relationship

modelBuilder.Entity<Destination>()
.HasMany(d => d.Lodgings)
.WithOptional(l => l.Destination);

 

 

 

目录
相关文章
|
XML 中间件 开发工具
SAP Fiori Tools 和对应的 CLI (Command Line Interface)
SAP Fiori Tools 和对应的 CLI (Command Line Interface)
SAP PM入门系列23 - IL07 Functional Location List (Multilevel)
SAP PM入门系列23 - IL07 Functional Location List (Multilevel)
SAP PM入门系列23 - IL07 Functional Location List (Multilevel)
|
开发框架 .NET
SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法
SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法
162 0
SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法
另一种无法enable ABAP source code tool的原因
另一种无法enable ABAP source code tool的原因
92 0