Migrating From NHibernate to Entity Framework 6
Does anyone know if there is a way to do something like Nhibernate's ReferencesAny
in EntityFramework?
Background
I've been tasked with updating an application that uses NHibernate (specifically version 2.1.2.4000). The company would really prefer to go with Entity Framework going forward. Ideally I would not like to have to change the Database schema (deal with DBA's), but I'm having issues figuring out how to map an entity that uses ReferencesAny
to something similar in Entity Framework.
My Nhibernate Mapping Reference:
//this is in a Spectator Mapping class, which isn't related at all to the
// Player, Judge, or Viewer
mapping.ReferencesAny(p => p.Owner)
.EntityTypeColumn("owner")
.EntityIdentifierColumn("owner_id")
.AddMetaValue<Player>("player")
.AddMetaValue<Judge>("judge")
.AddMetaValue<Viewer>("viewer")
.IdentityType<int>();
Player
, Judge
, and Viewer
all descend from the same base abstract class Person
but are stored in the Database as separate tables (with there not being a table for Person
).
I haven't been able to figure out how to set up my mappings in the Entity Framework classes to correctly model this relationship.
Does anyone have any thoughts or should I try to convince the powers that be to just keep NHibernate?
链接地址: http://www.djcxy.com/p/60272.html下一篇: 从NHibernate迁移到实体框架6