EntityFramework-Reverse-POCO-Code-First-Generator
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard
Add Support for EFCore Inheritance Workaround
Hello,
Per the the existing EF tickets:
https://github.com/dotnet/efcore/issues/7533 https://github.com/dotnet/EntityFramework.Docs/issues/594
It would be great if the generator could support adding in the work around to the generated context in order to generate this example
Would potentially also require a change to: AddParameterlessConstructorToDbContext
This allows the generated context to work out of the box with DbContextPool and Inheritance.
Thanks.
Example link above contains:
I was able to resolve this without a hack by providing a protected constructor that uses DbContextOptions without any type. Making the second constructor protected ensures that it will not get used by DI.
public class MainDbContext : DbContext
{
public MainDbContext(DbContextOptions<MainDbContext> options)
: base(options)
{
}
protected MainDbContext(DbContextOptions options)
: base(options)
{
}
}
public class SubDbContext : MainDbContext
{
public SubDbContext (DbContextOptions<SubDbContext> options)
: base(options)
{
}
}