-
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
Index on a field of owned type #19180
Comments
Since index is on the property of the owned entity, it should be defined on owned entity too. percentageConfiguration.HasIndex(l => l.Value)
.IsClustered(false)
.HasName("IX_Iva_Percentage")
.IsUnique(); |
The problem is this index is specific to this table, no other table that uses this owned type will have it. |
In that case you need to get the reference to owned type again. ivaConfiguration.OwnsOne(i => i.Percentage).HasIndex(l => l.Value)
.IsClustered(false)
.HasName("IX_Iva_Percentage")
.IsUnique(); |
@Abcdma - There are few points to remember here
|
Thank you, was in a hurry and didn't even noticed that I forgot to change the extension method to the OwnsOne. It's working now. |
@smitpatel sorry to bring this up again, is it possible to do an index with a ivaConfiguration and Percentage property (from each)? Example with "
Gives this error:
Or is this not supported yet? Have you seen any workarounds? Thanks. |
See #11336 |
Is it possible to have a non clustered index on a field of a owned type? I have a value object that is being used in multiple entities and in one of them I want to create a index in one of the fields.
Mapped using the following implementation #15681 (comment)
Value Object:
Configuration:
Main entity configuration
Error:
The properties expression 'l => Convert(l.Percentage.Value, Object)' is not valid. The expression should represent a simple property access: 't => t.MyProperty'. When specifying multiple properties use an anonymous type: 't => new { t.MyProperty1, t.MyProperty2 }'. (Parameter 'propertyAccessExpression')
Stack trace
EF Core 3.1
The text was updated successfully, but these errors were encountered: