table-splitting

EF Core Table Splitting - One table to multiple classes

不想你离开。 提交于 2020-01-24 00:30:10
问题 My table has four columns and I want to split it between multiple classes. table1 key col1 col2 col3 col4 Class ClassA key col1 col2 class ClassB key col3 col4 modelBuilder.Entity().ToTable("table1"); modelBuilder.Entity().ToTable("table1"); Currently it give me System.InvalidOperationException: 'Cannot use table 'table1' for entity type 'ClassB' since it is being used for entity type 'ClassA' Is it possible in EF Core? Thanks 回答1: You may need a relationship defined like the following based

EF6 Table splitting vs shared primary key for multiple splits

谁说胖子不能爱 提交于 2019-12-23 12:57:16
问题 I am upgrading a legacy database system into .NET + Entity Framework 6 (code-first POCO) + PostgreSQL. For ease of programming, I wish to split a large table (200+ fields) into multiple entities, eg.: Franchise FranchiseLegalEntity FranchiseBilling FranchiseSignup FranchiseAllocation FranchiseCompliance FranchiseMiscellaneous FranchiseNotifications I was delighted to find EF6 supports "table splitting": mapping a single table to multiple entities to split the fields up. However attempting to

Entity Framework Table Splitting: not in the same type hierarchy / do not have a valid one to one foreign key relationship

江枫思渺然 提交于 2019-12-23 06:57:03
问题 I'm using Entity Framework 6 with a Code-First approach, and I want two entities to be put in the same table. What am I doing wrong? [Table("Review")] public class Review { public int Id { get; set; } public PictureInfo PictureInfo { get; set; } public int PictureInfoId { get; set; } } [Table("Review")] public class PictureInfo { [Key, ForeignKey("Review")] public int ReviewId { get; set; } public Review Review { get; set; } } The error I get: The entity types 'PictureInfo' and 'Review'