Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does DeleteByKey not use defined converter #487

Open
KillerBoogie opened this issue May 12, 2022 · 0 comments
Open

Why does DeleteByKey not use defined converter #487

KillerBoogie opened this issue May 12, 2022 · 0 comments
Assignees

Comments

@KillerBoogie
Copy link

Description

We implement keys with dedicated value objects, e.g. AccountId. In the configuration for the entity a converter is provided with HasConversion().

entity.Property(e => e.Id).HasColumnName("AccountId").HasConversion(DBConverter_SharedKernel.AccountIdConverter);

It works fine with EF Core commands. I tested DeleteByKey. With accountId being of type AccountId I expected to call the method with

_dbContext.Person.DeleteByKey(accountId);

Exception

At runtime an exception is thrown:
System.ArgumentException: 'No mapping exists from object type Elwis.SharedKernel.Domain.AccountId to a known managed provider native type.'

Workaround

When I use the Guid value that is encapsulated by AccountId the command works:

_dbContext.Person.DeleteByKey(accountId.Value);

The signature of Person.DeleteByKey shows the type AccountId. I don't understand why the conversion doesn't work.

Further technical details

  • EF Core: 6.0.4
  • EF Extensions version:6.13.18
  • Database Provider: SQL Server
@JonathanMagnan JonathanMagnan self-assigned this May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants