Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 具有指定外键列名的TPT_Entity Framework_Inheritance - Fatal编程技术网

Entity framework 具有指定外键列名的TPT

Entity framework 具有指定外键列名的TPT,entity-framework,inheritance,Entity Framework,Inheritance,正在尝试使用现有模式在EF Core 5中应用TPT继承。如果列名与父表不完全匹配,如何指定子表的外键列名?在文档示例中,我们没有Pets.Id,而是Pets.PetId: CREATE TABLE [Animals] ( [Id] int NOT NULL IDENTITY, [Species] nvarchar(max) NULL, CONSTRAINT [PK_Animals] PRIMARY KEY ([Id]) ); CREATE TABLE [Pets] (

正在尝试使用现有模式在EF Core 5中应用TPT继承。如果列名与父表不完全匹配,如何指定子表的外键列名?在文档示例中,我们没有Pets.Id,而是Pets.PetId:

CREATE TABLE [Animals] (
    [Id] int NOT NULL IDENTITY,
    [Species] nvarchar(max) NULL,
    CONSTRAINT [PK_Animals] PRIMARY KEY ([Id])
);

CREATE TABLE [Pets] (
    *[PetId] int NOT NULL*,
    [Name] nvarchar(max) NULL,
    CONSTRAINT [PK_Pets] PRIMARY KEY ([PetId]),
    CONSTRAINT [FK_Pets_Animals_Id] FOREIGN KEY ([PetId]) REFERENCES [Animals] ([Id]) ON DELETE NO ACTION
);

您还应该包括相关的实体框架代码。好问题,看起来您不能。请在他们的GitHub问题跟踪器上发布问题/功能请求。