开发者

EF4 Code Only - Map Columns to Property Complex type

I have a table like this:

I want to map it to a model like this:

  • Name
  • Resources
    • Tree
    • Iron
    • Clay
  • Added

In makes sense to map it like this, when working with it in my program, but doing it that way in the databse would just make it more complex ... not would not add any useful things.

Is it possible with EF4 Code ONly?


public class Sample
{
   public int Id { get; set;}  // primary key required
   public string Name {get;set;}
   public DateTime Added{get;set;}

}

 public class Resource
 {
      //  no Id defined here
      public string Tree{get;set;}
      public string Iron { get;set;}
      public string Clay { get;set;}
  }

 public class SampleDB : DbContext
 {
      //public DbSet<Resource> Resources { get; set; } // should not be there
        public DbSet<Sample> Samples { get; set; }
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜