-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Improve exception message for instance or inline value converter with compiled model #25738
Labels
area-model-building
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-enhancement
Milestone
Comments
@rlgordey The key part about this message is the word "type" in, "Use 'HasConversion' to configure the value converter type." This means you need to create a ValueConverter type and configure that type in the model, rather than using inline conversion expressions. We will try to make this exception message clearer. |
@ajcvickers I have tried ... var converter = new ValueConverter<string, string>(
v => v.PadRight(15),
v => v.TrimEnd());
modelBuilder.Entity<Customer>()
.Property(e => e.Custnmbr)
.HasConversion(converter); With the same error. |
@rlgordey Hopefully this is clearer:
|
ajcvickers
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Sep 1, 2021
ajcvickers
changed the title
Exception when trying to run Optimize-DbContext
Improve exception message for instance or inline value converter with compiled model
Sep 1, 2021
ajcvickers
added a commit
that referenced
this issue
Sep 2, 2021
…ompiled model (#25816) * Be more explicit about which overloads of HasConversion to use with compiled model Fixes #25738 * Update src/EFCore.Design/Properties/DesignStrings.resx Co-authored-by: Andriy Svyryd <[email protected]> * Update src/EFCore.Design/Properties/DesignStrings.resx Co-authored-by: Andriy Svyryd <[email protected]> Co-authored-by: Andriy Svyryd <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-model-building
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-enhancement
I have a Customer Entity configured in my DbContext.ModelBuilder as:
The entity that was scaffolded is:
When I run
Optimize-DbContext
I get this exception:Even though it is using 'HasConversion'.
EF Core version: 6.0.0-rc.2.21426.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: net6.0
Operating system: Windows 10
IDE: Visual Studio 2022 17.0.0 Preview 3.1
The text was updated successfully, but these errors were encountered: