Page 1 of 1

EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Wed 18 Dec 2019 11:51
by laurensb
Querying for specific types in an inheritance hierarchy generates invalid queries.

Given a simple hierarchy with EntityMapping:

Code: Select all

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
	modelBuilder.Entity<BeastRider>().ToTable("BEAST_RIDER");
	modelBuilder.Entity<BeastRider>().HasKey(_ => _.Id);
	modelBuilder.Entity<BeastRider>().Property(_ => _.Id).HasColumnName("ID");
	modelBuilder.Entity<BeastRider>().Property(_ => _.Name).HasColumnName("NAME");
	
	modelBuilder.Entity<BeastRider>()
		.HasDiscriminator<string>("DISCRIMINATOR")
		.HasValue<BeastRider>(nameof(BeastRider))
		.HasValue<BirdRider>(nameof(BirdRider));
	modelBuilder.Entity<BeastRider>().Property("DISCRIMINATOR").HasMaxLength(50);
}
Querying for entities of type BirdRider generates invalid SQL queries:

Code: Select all

// Both methods of querying derived entities generate
// ... WHERE "b".DISCRIMINATOR = TO_NCLOB('BirdRider')
// resulting in 'ORA-00932: inconsistent datatypes: expected - got NCLOB'
var birdRider = context
	.Set<BirdRider>()
	.FirstOrDefault();

var beastRider = context
	.Set<BeastRider>()
	.FirstOrDefault(_ => _ is BirdRider);
A repository reproducing the bug can be found here.

Reproducible for:
  • Devart.Data.Oracle.EFCore: 9.9.887
  • Microsoft.EntityFrameworkCore.Relational: 3.0.1 & 3.1.0
  • .NET Core SDK versions: 3.0.101 & 3.1.100
  • .NET Core Runtime versions: 3.0 & 3.1

Re: EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Thu 26 Dec 2019 12:49
by Shalex
Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

Re: EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Thu 23 Jan 2020 07:33
by laurensb
Any news on this? As there is no workaround available for this issue, it is blocking us from upgrading to entity framework core 3.

Re: EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Fri 24 Jan 2020 18:52
by Shalex
The bug with querying types in inheritance hierarchy via EF Core 3 is fixed. The internal build with the fix is available at https://download.devart.com/nuget_oracle_9_10_932.zip.

Re: EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Mon 27 Jan 2020 07:32
by laurensb
Thanks! When are the latest fixes due to be released officially?

Re: EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Tue 28 Jan 2020 10:17
by Shalex
The new public build will be released in several weeks. There is no exact timeframe at the moment.

Re: EF Core 3 query type in inheritance hierarchy generates invalid query

Posted: Mon 02 Mar 2020 17:27
by Shalex
dotConnect for Oracle v9.11.951 is released: viewtopic.php?f=1&t=39884.