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

HasKey(p => new { p.Id, p.ComplexType.Property }) does not seem to work #32350

Closed
michelbieleveld opened this issue Nov 20, 2023 · 2 comments
Closed

Comments

@michelbieleveld
Copy link

michelbieleveld commented Nov 20, 2023

Trying to specify the HasKey on the Id and a Property of complex type on that same object. Considering it is just a normal column there shouldn't be an issue, I think, to be able to specify the above. However, I get the following error:

The exception 'The expression 'p => new <>f__AnonymousType0`2(EventId = p.EventId, Address = p.EmailAddress.Address)' is not a valid member access expression. The expression should represent a simple property or field access: 't => t.MyProperty'. When specifying multiple properties or fields, use an anonymous type: 't => new { t.MyProperty, t.MyField }'. (Parameter 'memberAccessExpression')' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Process terminated with exit code 1

As an alternative is there a standard way of providing the columns by string ?

@michelbieleveld
Copy link
Author

Maybe duplicate of #31246 not sure.

@michelbieleveld michelbieleveld changed the title HasIndex(p => new { p.Id, p.ComplexType.Property } does not seem to work HasKey(p => new { p.Id, p.ComplexType.Property }) does not seem to work Nov 20, 2023
@roji
Copy link
Member

roji commented Nov 20, 2023

Duplicate of #31246

@roji roji marked this as a duplicate of #31246 Nov 20, 2023
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants