I'm making a software for electronic invoices. So each invoice(and every entity as well) in the system will have an universal GUID Id as the primary key but I want another auto incremented Integer column that will increments it's value according to the provider(user) that is issuing the invoice. For example: I have a provider A that has 10 invoices and each invoice has a number that start at 1 in ascending mode but everyone has an unique GUID and a provider B that has the same invoices with the same ascending number starting at 1 but again with unique GUIDs. This numbers help for searching more easily in the system, instead of searching millions invoices in the database by the GUID, you just put the invoice number that is attached to the provider and it's much more clear than simply putting an extensive GUID in the case for printing it. I hope I was clear.
Here the code:
public void Configure(EntityTypeBuilder<Invoice> builder)
{
builder.HasKey(x => x.Id); //GUID
builder.Property(x => x.Title)
.IsRequired()
.HasMaxLength(100);
builder.Property(x => x.Description)
.IsRequired();
builder.Property(x => x.Date)
.IsRequired();
builder.Property(x => x.TotalValue)
.IsRequired();
builder.Property(x => x.TaxValue)
.IsRequired();
builder.HasOne(x => x.Taker);
builder.HasOne(x => x.Provider);
builder.HasOne(x => x.ServiceType);
}