views:

31

answers:

1

I am writing my code as suggested,

public class A 
{
    public int id {get;set;}
    public string Astring {get;set;}
}

public class B : A
{
    public string Bstring {get;set;}
}

builder.Entity<A>().MapHierarchy( u=> new { ... }).ToTable("A");
builder.Entity<B>().MapHierarchy( u=> new { ... }).ToTable("B");

... = I have all the properties mentiond and u.Id in both.

I also have DbSet<A> A {get;set;} and DbSet<B> B {get;set;} and ObjectSet properties for both when I use Model builder

builder.Entity<A>
builder.Entity<B>

This results in Table A being created with a discriminator column and Id, Astring, Bstring. This is the default TPH mapping, not sure why this is happening. Thanks

A: 

http://blog.cincura.net/231783-ultimate-efv4-ctp4-code-first-full-mapping-example-using-firebird/

The Author, Translator part in the example above has the correct TPT solution, for some reason the example on

http://romiller.com/2010/09/29/ef-ctp4-tips-tricks-code-first-inheritance-mapping/

dosn't work for me

Neville Chinan