I have the following ValueMember
public class ApplicationName : ValueObject
{
public string FirstName { get; }
public string LastName { get; }
protected ApplicationName()
{
}
private ApplicationName(string firstName, string lastName)
: this()
{
FirstName = firstName;
LastName = lastName;
}
etc...
}
in the following class (Asp.Net Core IdentityUser)
public class ApplicationUser : IdentityUser<long>
{
public ApplicationUserName Name { get; set; }
}
Those columns (FirstName, LastName) along with the Email column are part of a db index. I have the following in my dbcontext:
modelBuilder.Entity<ApplicationUser>(x =>
{
x.OwnsOne(p => p.Name, p =>
{
p.Property(pp => pp.FirstName).HasColumnName("FirstName");
p.Property(pp => pp.LastName).HasColumnName("LastName");
});
x.HasIndex(p => new { p.Name, p.Email });
});
When I run my app I get the following error System.InvalidOperationException: ''Name' cannot be used as a property on entity type 'ApplicationUser' because it is configured as a navigation.'
How can I set the index without receiving the above error?