table-per-hierarchy

Possible to call a stored procedure on a Table-Per-Hierarchy table in EF Core 3.1?

僤鯓⒐⒋嵵緔 提交于 2020-06-27 16:46:09
问题 I'm moving from EF Core 2.2 to 3.1. One breaking change (#15392) was that it no longer composed over stored procedures, so you had to add 'AsEnumerable'. That usually works, but I have a stored procedure call on a TPH table where that fails: My call to the SPROC is: SqlParameter authorizedUserID_p = new SqlParameter("@authorizedUserID", authorizedUser.ID); IEnumerable<Post> query = context.Posts.FromSqlRaw<Post>("Post.USP_ReadPost @ID, @AuthorizedUserID", parameters: new[]{ parentID_p,

Does Breeze work with Table Per Hierarchy (TPH)

廉价感情. 提交于 2020-01-25 00:38:06
问题 I'm trying to plug BreezeJs into an existing datastructure and getting an error in the meta data fetch. I can replicate this by adding the following to the CarBones sample namespace CarBones.Models { public abstract class VanBase { public int Id { get; set; } public string Manufacturer { get; set; } public int Wheels { get; set; } } public class BasicVan : VanBase { } public class LiveriedVan : VanBase { public string Livery { get; set; } } } then in the context public DbSet<VanBase> Vans {

Entity Framework 4 - TPH Inheritance in Features CTP5 (code first) with “IS NULL” discriminator

谁说胖子不能爱 提交于 2019-12-31 04:57:05
问题 Hey guys, I'm trying to create a TPH mapping on a hierarchy where the discriminating clause is the classical "IS NOT NULL" / "IS NULL" case. Here is the example, database wise: CREATE TABLE info.EducationTypes ( ID INT NOT NULL PRIMARY KEY, Name NVARCHAR(64) NOT NULL, FKParentID INT NULL REFERENCES info.EducationTypes(ID) ) the idea is to have a class hierarchy like the following one: public abstract class EducationType { public int ID { get; set; } public string Name { get; set; } } public

EF: Can I mix TPH and TPT when abstract base and a few concrete types are in TPH-table and other types have their own table?

安稳与你 提交于 2019-12-24 00:32:43
问题 First of all, these questions are similar but definitely not the same: Can I mix Table per Hierarchy and Table per Type in Entity Framework? - Refers to a different scenario. Entity Framework: mix table per type and table per hierarchy - Yet another scenario, that despite accepting answer to first scenario is not related to it (*). (*) Second of all, I have sucessfully mixed table-per-type and table-per-hierarchy in Entity Framework, when base entity is mapped using table-per-entity and the

Entity Framework one-to-many with table-per-hierarchy creates one foreign key column per subclass

时光总嘲笑我的痴心妄想 提交于 2019-12-23 07:25:00
问题 I have a Garage which contains Cars and Motorcycles . Cars and motorcycles are Vehicles . Here they are: public class Garage { public int Id { get; set; } public virtual List<Car> Cars { get; set; } public virtual List<Motorcycle> Motorcycles { get; set; } public Garage() { Cars = new List<Car>(); Motorcycles = new List<Motorcycle>(); } } public abstract class Vehicle { public int Id { get; set; } public string Make { get; set; } public string Model { get; set; } } public class Car : Vehicle

Entity Framework one-to-many with table-per-hierarchy creates one foreign key column per subclass

二次信任 提交于 2019-12-23 07:24:56
问题 I have a Garage which contains Cars and Motorcycles . Cars and motorcycles are Vehicles . Here they are: public class Garage { public int Id { get; set; } public virtual List<Car> Cars { get; set; } public virtual List<Motorcycle> Motorcycles { get; set; } public Garage() { Cars = new List<Car>(); Motorcycles = new List<Motorcycle>(); } } public abstract class Vehicle { public int Id { get; set; } public string Make { get; set; } public string Model { get; set; } } public class Car : Vehicle

Multiple Inheritance with Entity Framework with TPH

青春壹個敷衍的年華 提交于 2019-12-23 04:09:45
问题 Further to this question: Entity Framework TPH with multiple abstract inheritance and VS.2008 sp1 .net 3.5 c# I decided to add Organizations and a School. Organization(abstract) inherits from Party, and School(concrete) inherits from Organization. I get the error: Error 1 Error 3034: Problem in Mapping Fragments starting at lines 73, 93: Two entities with different keys are mapped to the same row. Ensure these two mapping fragments do not map two groups of entities with different keys to the

Entity Framework 6 & TPH inheritance: Map properties with the same name to same column by default

有些话、适合烂在心里 提交于 2019-12-21 04:23:16
问题 As of EF6 it is possible to do something like this when configuring Entity mappings using Table Per Hierarchy inheritance: public class MyContext : DbContext { public DbSet<Device> Devices { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<ABatteryPoweredDevice>().Property(c => c.BatteryLevel).HasColumnName("BatteryLevel"); modelBuilder.Entity<ADifferentBatteryPoweredDevice>().Property(c => c.BatteryLevel).HasColumnName("BatteryLevel"); }

EF6 - TPH foreign key mapping in derived classes using base class property

自作多情 提交于 2019-12-19 21:46:29
问题 I am using Entity Framework 6.0.2 with an existing database in which tags are stored in a single table that looks like this: Id : int, primary key TagType : string, determine the type of tag, either "usertag" or "movietag" ItemId : int, contains the Id of the item to which is referred (either a User Id or a Movie Id) The following classes describe this situation: public class User { public int Id { get; set; } } public class Movie { public int Id { get; set; } } public abstract class Tag {

EF6 - TPH foreign key mapping in derived classes using base class property

走远了吗. 提交于 2019-12-19 21:46:23
问题 I am using Entity Framework 6.0.2 with an existing database in which tags are stored in a single table that looks like this: Id : int, primary key TagType : string, determine the type of tag, either "usertag" or "movietag" ItemId : int, contains the Id of the item to which is referred (either a User Id or a Movie Id) The following classes describe this situation: public class User { public int Id { get; set; } } public class Movie { public int Id { get; set; } } public abstract class Tag {