You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I found myself in a strange situation that I don't know how to setup in EF Core.
I have the following 2 entities:
// Primary key is CountryCode+ServiceProdId+ModelId
public sealed class LTRServiceProduct
{
[StringLength(2)]
public string CountryCode { get; init; } = null!;
public int ServiceProdId { get; init; }
public int ModelId { get; init; }
public IEnumerable<LTRServiceProductFactor> Factors { get; init; } = new List<LTRServiceProductFactor>();
....
}
[PrimaryKey(nameof(ServiceProdId), nameof(FactorId))]
public sealed class LTRServiceProductFactor
{
public int ServiceProdId { get; init; }
public int FactorId { get; init; }
}
I want to create a relationship (even without foreign keys, which may be a case related to #15854) where i relate those 2 entities just using ServiceProdId.
In my case, this two entities are readonly on database, so the application will never write to those tables, and the relationship will always start from LTRServiceProduct to LTRServiceProductFactor (so i'll never try to get all the Products related to a ProductFactor because it has no sense).
How should I configure this navigation? Building a Many-to-Many is wrong because basically the bridge table is bigger than the destination table, and also requires me to populate that table with a crossjoin of data that shouldn't be needed and would be redundant.
But a One-to-Many fails because it enforces a unique constraint during migration on ServiceProdId when it's not unique.
Any help is appreciated.
Thank you
Alex
The text was updated successfully, but these errors were encountered:
Hi, I found myself in a strange situation that I don't know how to setup in EF Core.
I have the following 2 entities:
I want to create a relationship (even without foreign keys, which may be a case related to #15854) where i relate those 2 entities just using
ServiceProdId
.In my case, this two entities are readonly on database, so the application will never write to those tables, and the relationship will always start from
LTRServiceProduct
toLTRServiceProductFactor
(so i'll never try to get all the Products related to a ProductFactor because it has no sense).How should I configure this navigation? Building a Many-to-Many is wrong because basically the bridge table is bigger than the destination table, and also requires me to populate that table with a crossjoin of data that shouldn't be needed and would be redundant.
But a One-to-Many fails because it enforces a unique constraint during migration on ServiceProdId when it's not unique.
Any help is appreciated.
Thank you
Alex
The text was updated successfully, but these errors were encountered: