0

I have a table like this:

  • Name
  • Tree
  • Iron
  • Clay
  • Added

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?

Syska
  • 1,150
  • 7
  • 26

1 Answers1

1
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; }
 }
Jakkamma
  • 60
  • 1
  • 6
  • Well, yes ... its possible now with EF4 CTP5. Exactly as you write. Forget all about it. Thanks god for the mail notice :-). – Syska Dec 22 '10 at 08:18