-
Notifications
You must be signed in to change notification settings - Fork 256
Closed
Description
I'm using Ulid with EF Core and everything works fine when I use linq queries but the application throws an error when I use the ExecuteSqlInterpolatedAsync
I have this DbContext
public class ApplicationDbContext : DbContext
{
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder.Properties<Ulid>()
.AreUnicode(false)
.AreFixedLength(true)
.HaveMaxLength(26)
.HaveConversion<UlidToStringConverter>();
}
}The converter
internal class UlidToStringConverter : ValueConverter<Ulid, string>
{
public UlidToStringConverter()
: base(
convertToProviderExpression: x => x.ToString(),
convertFromProviderExpression: x => Ulid.Parse(x))
{
}
}This query throws
var id = Ulid.NewId();
await ApplicationAdminDbContext.Database.ExecuteSqlInterpolatedAsync(@$"
UPDATE app.""Roles""
SET ""Name"" = {name}
WHERE ""Id"" = {id}");Unhandled exception rendering component: The current provider doesn't have a store type mapping for properties of type 'Ulid'.
System.InvalidOperationException: The current provider doesn't have a store type mapping for properties of type 'Ulid'.
This query works
var id = Ulid.NewId();
var idForSql = id.ToString();
await ApplicationAdminDbContext.Database.ExecuteSqlInterpolatedAsync(@$"
UPDATE app.""Roles""
SET ""Name"" = {name}
WHERE ""Id"" = {idForSql}");Do you have any idea why is this happening and how should I solve that ?
Thanks a lot.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels