Skip to content

[Inheritance] INSERT derived class as base class #29637

@SuRGeoNix

Description

@SuRGeoNix

Hi, shouldn't be able to save C as B in db?
I've also noticed that INSERT statement will send NULLs properties while I was make them null to avoid sending them.

class A {}
class B : A {}
class C : B {}

DbSet<A> As
DbSet<B> Bs
DbSet<C> Cs

C c = new();

dbContext.Bs.Add(c);

Thanks,
John

Include provider and version information

EF Core version: 7
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 7.0
Operating system: Windows 10
IDE: Visual Studio 2022 17.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions