I've been experiencing very annoing issue.
I've many-to-many relation between my two entities (both of them have abstract base classes) and the relation is mapped in both configurations for entities.
The main entity (MedicalService) config:
Code: Select all
HasMany(t => t.Icd9Components).WithMany(m => m.MedicalServices).Map(m =>
{
m.MapLeftKey("SERVICE_ID");
m.MapRightKey("PROCEDURE_ID");
});
Code: Select all
HasMany(t => t.MedicalServices).WithMany(t => t.Icd9Components).Map(m =>
{
m.MapLeftKey("PROCEDURE_ID");
m.MapRightKey("SERVICE_ID");
});
Code: Select all
using (var context = new DomainContext())
{
var data = context.Icd9Extensions.ToList();
var newData = new MedicalServiceEntity
{
Icd9Components = new List()
};
newData.Icd9Components.Add(data[0]);
context.MedicalServices.Add(newData);
context.SaveChanges();
}
I've been using
6.8.341 oracle dotConnect
Entity Framework 4.1[/code]