table-per-type

Entity Framework Core: TPT

帅比萌擦擦* 提交于 2021-02-08 11:26:33
问题 .NET 5 preview 8 is just released and I've been testing the brand new TPT feature. I've installed the .NET 5 preview 8 Runtime and SDK. I created a .NET Core class library, installed the dotnet-ef preview 8 NuGet, updated the dotnet-ef tool with the following command (administrator): dotnet tool update --global dotnet-ef --version 5.0.0-preview.8.20407.4 I've build the following database model: public class MintPlayerContext : DbContext { // dotnet ef migrations add AddInitialEntities //

Entity Framework Core: TPT

巧了我就是萌 提交于 2021-02-08 11:26:30
问题 .NET 5 preview 8 is just released and I've been testing the brand new TPT feature. I've installed the .NET 5 preview 8 Runtime and SDK. I created a .NET Core class library, installed the dotnet-ef preview 8 NuGet, updated the dotnet-ef tool with the following command (administrator): dotnet tool update --global dotnet-ef --version 5.0.0-preview.8.20407.4 I've build the following database model: public class MintPlayerContext : DbContext { // dotnet ef migrations add AddInitialEntities //

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

一曲冷凌霜 提交于 2020-01-14 03:38:07
问题 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

Entity Framework Table Per Type Performance

早过忘川 提交于 2020-01-12 19:05:51
问题 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

Entity Framework Table Per Type Performance

匆匆过客 提交于 2020-01-12 19:04:13
问题 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

TPT inheritance with non-abstract base class in Code First

江枫思渺然 提交于 2020-01-02 18:16:09
问题 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; }

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 4.1 - TPT Eager Loading - “The ResultType of the specified expression is not compatible with the required type”

你离开我真会死。 提交于 2019-12-21 20:51:13
问题 I have a model with TPT inheritance. Location ( abstract ) Street ( derived from Location) GoogleStreetView ( 1 Street -> 0..1 GoogleStreetView ) Each of the above has it's own table. All was working fine until i added the "GoogleStreetView" table (which is backed by a PK/FK to Street). When i try and do this: var street = _locationRepository .Find() .OfType<Street>() .Include(x => x.GoogleStreetView) .SingleOrDefault(x => x.LocationId == 1); I get the error: The ResultType of the specified

Inheritance and composite foreign keys - one part of the key in base class, the other part in derived class

可紊 提交于 2019-12-17 20:35:31
问题 I am having problems to create an Entity Framework Code-First mapping for the following sample database schema (in SQL Server): Every table contains a TenantId which is part of all (composite) primary and foreign keys (Multi-Tenancy). A Company is either a Customer or a Supplier and I try to model this via Table-Per-Type (TPT) inheritance mapping: public abstract class Company { public int TenantId { get; set; } public int CompanyId { get; set; } public int AddressId { get; set; } public

Need help migrating existing model to include table per type inheritance

依然范特西╮ 提交于 2019-12-13 07:44:44
问题 The application I'm working on is a simple application for keeping track of client information (creating, viewing, editing). I'd like to expand the application to be able to include basic information about family members of the clients. I recently discovered the ability to use inheritance in entity framework and would like to create a simple inheritance hierarchy where clients inherit from a class called person because clients keep track of much of the same information as their family members