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

Add HasCharSet method for ComplexPropertyBuilder #1984

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

trejjam
Copy link
Contributor

@trejjam trejjam commented Mar 4, 2025

Hi, this aims to fix an invalid snapshot generated when setting the charset on a ComplexProperty property.

Snapshot.cs(443,71): error CS1503: Argument 1: cannot convert from 'Microsoft.EntityFrameworkCore.Metadata.Builders.ComplexTypePropertyBuilder<string>' to 'Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder'
b.ComplexProperty<Dictionary<string, object>>("Figure", "...Entity.Figure#File", b1 =>
{
    b1.IsRequired();

    b1.Property<string>("Path")
        .IsRequired()
        .HasMaxLength(256)
        .HasColumnType("varchar(256)")
        .HasColumnName("FigurePath");

        MySqlPropertyBuilderExtensions.HasCharSet(b1.Property<string>("Path"), "utf8mb4");
});

@lauxjpn
Copy link
Collaborator

lauxjpn commented Mar 7, 2025

Yes, adding HasCharSet() extension methods for complex type properties makes sense.

A current workaround should be to just specify a collation instead of a charset (which is more precise anyway).

@lauxjpn lauxjpn self-requested a review March 7, 2025 00:25
@trejjam trejjam force-pushed the feature/complex-property-charset branch from 368f9d1 to dc482ac Compare March 7, 2025 15:11
Copy link
Collaborator

@lauxjpn lauxjpn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comments below, I think the ComplexTypePropertyBuilder extension methods should get their own class/file.

@trejjam trejjam force-pushed the feature/complex-property-charset branch 2 times, most recently from cf81792 to 19a749c Compare March 8, 2025 19:05
@trejjam trejjam requested a review from lauxjpn March 8, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants