开发者

TPT mapping Entity Framework CTP4 behaving like TPH

开发者 https://www.devze.com 2023-01-23 07:48 出处:网络
I am writing my code as suggested, public class A { public int id {get;set;} public string Astring {get;set;}

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开发者_Go百科 why this is happening. Thanks


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

0

精彩评论

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