question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

c# Oracle.EntityFrameworkCore 5.21.3 System.Guid handling

See original GitHub issue

Since the upgrade of Oracle.EntityFrameworkCore from 5.21.1 towards 5.21.3 I face the following problem: All my entities have a primairy key based on a GUID (maybe not the best idea but ok)

Table definition

create table "TABLE"
(
  id                              RAW(16) not null,
  ...
);

To get an entity by a guid I use

public TEntity GetById(Guid id)
{
    return DoQuery().SingleOrDefault(x => x.Id == id);
}

In 5.21.1 this result correctly in an entity using

info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (11ms) [Parameters=[:id_0='e6538e18-e795-45d4-894c-aa321a5c2e58' (DbType = Binary)], CommandType='Text', CommandTimeout='0']
      SELECT "r"."ID", <omitted columns>
      FROM "TABLE" "r"
      WHERE "r"."ID" = :id_0
      FETCH FIRST 2 ROWS ONLY

in 5.21.3 the query doesn’t return a result while logging the same query

With both versions the database is the same no other packages are upgraded and no changes applied to the code,. It feels like something happend in the handling of translating of guids. Is there something changed?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
anderjoycommented, Aug 25, 2021

@Shortcheese This workaround solved the conversion “problem” with Guid:

public override void OnModelCreating(ModelBuilder modelBuilder)
{
       ....

	var converter = new ValueConverter<Guid, byte[]>(
		to => to.ToByteArray(),
		from => new Guid(from));

	foreach (var property in modelBuilder.Model.GetEntityTypes()
            .SelectMany(t => t.GetProperties())
	    .Where(p => p.ClrType == typeof(Guid) ||
                        p.ClrType == typeof(Guid?)))
	{
		property.SetValueConverter(converter);
	}
}
2reactions
alexkehcommented, Aug 6, 2021

Thanks for reporting! I’ve been able to reproduce this problem and have filed bug 33198936. One of the dev team members will review and fix the bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle.EntityFrameworkCore data type Guid
EntityFramwork and use the new Oracle.EntityFrameworkCore. My project seems to build, but only one datatype I used has a problem. The database ...
Read more >
Is it possible to use a Guid with Oracle's Entity Framework ...
We have been using Devart's entity framework core implementation but are experiencing extremely poor performance. We originally went with ...
Read more >
Changes in This Release for Oracle Data Provider for .NET
The event handler provides a centralized, standardized location for connection initialization. See also ConnectionOpen for more information. Deprecated Features.
Read more >
5 Oracle Data Provider for .NET Entity Framework Core
Oracle Data Provider for .NET (ODP.NET) Entity Framework (EF) Core is a database provider that allows Entity Framework Core to be used with...
Read more >
Oracle.EntityFrameworkCore 5.21.1
Oracle Data Provider for .NET (ODP.NET) Entity Framework Core for Oracle Database.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found