2

Any body know if it is possible to create index based on entity field and owned value object field using code-first in entity framework - dotnet core 3.

I have entity with this 2 fields and several more:

public string SomethingId { get; private set; }
public EmailAddress Email { get; private set; }

I try to create index in this way:

builder.HasIndex(p => new {p.Email.Address, p.SomethingId}).IsUnique();

But it doesn't work.

I get an error

The properties expression 'p => new <>f__AnonymousType3`2(Address = p.Email.Address, SomethingId = p.SomethingId)' 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 }'.

Thanks for every suggestion if it is possible to deal with this problem ;)

vezuwio
  • 23
  • 3

0 Answers0