Is it possible to create a multicolumn index without defining a shadow property in the model by using Fluent API?
<code>public class Domain
{
public long Id { get; set; }
public string Hostname { get; set; } = null!;
public User User { get; set; } = null!;
}
</code>
<code>public class Domain
{
public long Id { get; set; }
public string Hostname { get; set; } = null!;
public User User { get; set; } = null!;
}
</code>
public class Domain
{
public long Id { get; set; }
public string Hostname { get; set; } = null!;
public User User { get; set; } = null!;
}
By adding a UserId
property to the Domain
class it would be possible to create a composite key the following way:
<code>builder.HasIndex(d => new {d.Hostname, d.UserId})
</code>
<code>builder.HasIndex(d => new {d.Hostname, d.UserId})
</code>
builder.HasIndex(d => new {d.Hostname, d.UserId})
The problem with this is that the UserId
property is now in the model. Is this the only way to create a composite index?
HasIndex("Hostname", "UserId")
– this works, but it creates 2 separate indexes and not a composite one.