table-per-type

EF Table Per Type with Navigation property on Sub Type Table

痞子三分冷 提交于 2019-12-11 06:29:51
问题 I'm hoping someone out in the SO community will be able to help me out here. Simplified Background: I'm using Entity Framework V1 to build my class structure that is outlined below, I'm using Table Per Type to persist my inherited objects: Employee CaseA : Case CaseB : Case CaseC : Case CaseB has a Navigational Property to Employee I have a Repository that returns an ObjectQuery. If the type of Case is actually CaseB, I need to include the Employee object within the graph. I can't .Include(

Entity Framework 4.2 - How to realize TPT-Inheritance with Database-generated Primarykey Value?

淺唱寂寞╮ 提交于 2019-12-08 07:53:27
问题 I want to use the EF (4.2) in the following scenario: There exists a database already (so I chose the database-first approach) and it is a SQL Anywhere DB. I want to use persistence-ignorant business objects, so I use the DbContext Template to generate POCO classes from the EDM. There is one simple inheritance hierarchy among my entities: an abstract base entity and two concrete derived entities. In the database there is one table for each type of the inheritance hierarchy (Table-Per-Type

Entity Framework / code first / table-per-type inheritance - implementing a one-to-many association between a derived class and a concrete class

天大地大妈咪最大 提交于 2019-12-07 17:09:24
问题 I'm using MVC4 in VS2012, and I'm following a table-per-type inheritance approach. I'm trying to use the Seed() method to add data to my database. I have the following classes: LandLord [Table("Landlord")] public class Landlord : UserProfile { // A Landlord can have many ResidentialProperties [ForeignKey("ResidentialPropertyId")] public virtual ICollection<ResidentialProperty> ResidentialProperties { get; set; } } ResidentialProperty [Table("ResidentialProperty")] public class

Entity Framework 4 - TPT Inheritance in Features CTP5 (code first): rename foreign key column on inherited table

ぐ巨炮叔叔 提交于 2019-12-07 08:14:32
I'm trying to convert an xml Entity Framework model to Code First (CTP5) one. I have to model a hierarchy which fits quite well the TPT pattern. The only problem I have is that the primary key/foreign key of the "inheriting" table has a different name from the primary key of the base class. These are the relevant fields of the involved tables CREATE TABLE site.Domains ( ID INT NOT NULL PRIMARY KEY, Domain NVARCHAR(128) NOT NULL ) CREATE TABLE site.MainSites ( FKDomainID INT NOT NULL PRIMARY KEY REFERENCES site.Domains(ID) ) CREATE TABLE site.SisterSites ( FKDomainID INT NOT NULL PRIMARY KEY

Entity Framework 4.2 - How to realize TPT-Inheritance with Database-generated Primarykey Value?

╄→гoц情女王★ 提交于 2019-12-06 15:19:45
I want to use the EF (4.2) in the following scenario: There exists a database already (so I chose the database-first approach) and it is a SQL Anywhere DB. I want to use persistence-ignorant business objects, so I use the DbContext Template to generate POCO classes from the EDM. There is one simple inheritance hierarchy among my entities: an abstract base entity and two concrete derived entities. In the database there is one table for each type of the inheritance hierarchy (Table-Per-Type Strategy). Each of these three tables has a primary key column ( Id , type: integer ), and the association

TPT inheritance with non-abstract base class in Code First

半世苍凉 提交于 2019-12-06 06:35:49
I want to create a TPT mapping where the base class itself holds information and the derived classes just extend it. Basically, I've got a base class, and a few derived classes, and I'm wondering how to handle their mapping. Here's a ridiculously simplified example: [Table("Task")] public class Task : TaskBase { // No properties... This is just a "Task", not either an internal nor external one. } [Table("InternalTask")] public class InternalTask : TaskBase { public int UserId { get; set; } public virtual User User { get; set; } } [Table("ExternalTask")] public class ExternalTask : TaskBase {

Entity Framework 5 table-per-type update, change sub type but keep same base type

南笙酒味 提交于 2019-12-05 22:29:13
问题 I have a simple hierarchy public abstract class CommunicationSupport { public SupportTypeEnum Type { get; set; } public Country Origin { get; set; } // National or Foreign support } public class TelecomSupport : CommunicationSupport { public string Number { get; set; } } public class PostalSupport : CommunicationSupport { public Address Address { get; set; } } I plan to use the Table-per-type hierarchy for my DB. So 3 tables will be created, one base and two child using the same PK as the

Entity Framework Table Per Type Performance

 ̄綄美尐妖づ 提交于 2019-12-04 05:15:40
So it turns out that I am the last person to discover the fundamental floor that exists in Microsoft's Entity Framework when implementing TPT (Table Per Type) inheritance. Having built a prototype with 3 sub classes, the base table/class consisting of 20+ columns and the child tables consisting of ~10 columns, everything worked beautifully and I continued to work on the rest of the application having proved the concept. Now the time has come to add the other 20 sub types and OMG, I've just started looking the SQL being generated on a simple select, even though I'm only interested in accessing

Entity Framework 5 table-per-type update, change sub type but keep same base type

五迷三道 提交于 2019-12-04 03:35:58
I have a simple hierarchy public abstract class CommunicationSupport { public SupportTypeEnum Type { get; set; } public Country Origin { get; set; } // National or Foreign support } public class TelecomSupport : CommunicationSupport { public string Number { get; set; } } public class PostalSupport : CommunicationSupport { public Address Address { get; set; } } I plan to use the Table-per-type hierarchy for my DB. So 3 tables will be created, one base and two child using the same PK as the base. My problem is that I want to be able to update a CommunicationSupport by changing it's type. Let's

How to implement inheritance Table-Per-Type in Entity Framework 4.3 via Code First approach?

陌路散爱 提交于 2019-12-01 09:38:40
I have this class hierarchy in code: [Table("A")] public class A : IIdentification { public int id { get; set; } } [Table("B")] public class B : A { //some properties here public Aid { get; set;} ForeignKey("Aid"); public A A { get; set; } } [Table("C")] public class C : B { //some properties here public Bid { get; set; } ForeignKey("Bid"); public B B { get; set; } } [Table("D")] public class D : C { public Cid { get; set;} ForeignKey("Cid"); public C C { get; set; } } How can I make one table with a foreign key for each class or any other possible correct way? Maybe someone could post some