How do I map a small object graph using Entity Framework Code First 4.1? -


i have small object graph i'm using:

public struct address {     public string addressline1 { get; set; }     public string addressline2 { get; set; }     etc... }  public class user {     public address homeaddress { get; set; }     public address workaddress { get; set; }     public string firstname { get; set; }     etc... } 

using entity framework 4.1, how map structure 1 table they're mapped columns like:

homeaddressline1 homeaddressline2 workaddressline1 workaddressline2 firstname lastname etc... 

ef doesn't support structures. must use class address , map complex type:

public class address {     public string addressline1 { get; set; }     public string addressline2 { get; set; } }  public class user {     public int id { get; set; }     public address homeaddress { get; set; }     public address workaddress { get; set; }     public string firstname { get; set; } }   public class context : dbcontext {     protected override void onmodelcreating(dbmodelbuilder modelbuilder)      {         modelbuilder.entity<user>()                     .property(u => u.homeaddress.addressline1)                     .columnname("homeaddressline1");         // use same pattern columns of homeaddress , workaddress     } } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -