I am trying to make n-n relation with rel table using Fluent API but i am messed up with inconsistent column names.
I have Service
and Feature
objects simply like this:
public class Service
{
[Key]
public int ServiceID { get; set; }
public int FirmID { get; set; }
}
public class Feature
{
[Key]
public int FeatureID { get; set; }
public string Description { get; set; }
}
And I have already defined relation table:
ServiceFeature
--------------
ServiceID
FeatureID
Normally I can map like this:
modelBuilder.Entity<Service>()
.HasMany(e => e.Features)
.WithMany(e => e.Services)
.Map(m => m.ToTable("ServiceFeature").MapLeftKey("ServiceID").MapRightKey("FeatureID"));
But here is the problem: ServiceID
from ServiceFeature
is actually FirmID
from Service
and I couldn't figure out how to map it like this.
Is there any way to define column names for each table?