EF Core 3 query type in inheritance hierarchy generates invalid query

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
laurensb
Posts: 13
Joined: Thu 06 Jun 2019 07:44

EF Core 3 query type in inheritance hierarchy generates invalid query

Post by laurensb » Wed 18 Dec 2019 11:51

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

Shalex
Site Admin
Posts: 9023
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Thu 26 Dec 2019 12:49

Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

laurensb
Posts: 13
Joined: Thu 06 Jun 2019 07:44

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

Post by laurensb » Thu 23 Jan 2020 07:33

Any news on this? As there is no workaround available for this issue, it is blocking us from upgrading to entity framework core 3.

Shalex
Site Admin
Posts: 9023
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Fri 24 Jan 2020 18:52

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.

laurensb
Posts: 13
Joined: Thu 06 Jun 2019 07:44

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

Post by laurensb » Mon 27 Jan 2020 07:32

Thanks! When are the latest fixes due to be released officially?

Shalex
Site Admin
Posts: 9023
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Tue 28 Jan 2020 10:17

The new public build will be released in several weeks. There is no exact timeframe at the moment.

Post Reply