-
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
Support of unique Index with Owned types properties #12637
Comments
@AndriySvyryd, thoughts? |
@thiagomajesk You can just create the index on the owned type: modelBuilder.Entity<Foo>(x =>
{
x.OwnsOne(z => z.Buzz, zb =>
{
zb.Property(z => z.Description).HasColumnName("Buzz")
.UsePropertyAccessMode(PropertyAccessMode.FieldDuringConstruction)
.IsRequired();
zb.HasIndex(z => z.Description).IsUnique();
});
}); |
@AndriySvyryd This won't work because I don't want "Description" to be unique by itself, I want uniqueness on the pair: |
Then this is a duplicate of #11336, see the comments there for a workaround. |
@AndriySvyryd Ok, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I wonder if this is supported...
I have an owned type already configured and I wish to add a unique constraint that includes one of the owned type properties to prevent the user to insert two entities with "same" info.
For clarification:
The error I'm getting is...
Is there any currently supported way to get this working?
The text was updated successfully, but these errors were encountered: