2
Abstracting some details I have these classes:
public class Department: Entitie
{
public string Description { get; private set; }
public DateTime CreateDate { get; private set; }
public virtual ICollection<Service> Services {get; set;}
}
public class Service: Entitie
{
public string Description { get; set; }
public Guid DepartmentId { get; set; }
public virtual Department Department { get; set; }
}
public class DepartmentServiceRequest: Entitie
{
public Guid DepartmentId { get; set; }
public virtual Department Department { get; set; }
public virtual ICollection<Service> Services { get; set; }
}
The class DepartmentServiceRequest
is just one of my many attempts to make it work.
A Department lends several Services. A department can request one or more services from another department, and this needs to be mapped in advance. That is, it has the services it provides and the services it can order. The goal is not register a Service, is map what types he can register.
In the bank the result is this:
I don’t understand why he’s taking the Id of DepartmentServiceRequest
to the Service.
It is possible via mapping to inform that it should generate this associative table only with the Ids of Department
and Service
? This seems to me the most logical, thinking in a relational way.
Related: http://answall.com/questions/71261/mapping-complexo-entity-framework
– Leonel Sanches da Silva