We are trying to use EF
as a Business Entity Mapping model
. Instead of generating 1 table per class we would like to flatten out the tables (entity splitting) and generate a business object for the class, letting Entity Framework handle the CRUD.
In addition we have an existing database and cannot modify the schema. We have tried both code-first and database first solutions, but we are unable to get to our stated goal.
What we have:
public class Call
{
public int CallId {get;set;}
public DateTime callTime {get;set;}
public int PhoneTypeId {get; set;}
public virtual PhoneType PhoneType {get; set;}
}
public class PhoneType
{
public int PhoneTypeId {get ;set;}
public string TypeOfPhone {get ;set;}
}
What we want:
public class CallDetails
{
public int CallId {get;set;}
public DateTime callTime {get;set;}
public string TypeOfPhone {get; set;}
}
Edit
We are on ef 5 but can go up to ef 6.
Edit
To state the question clearer, I am looking for a way to flatten out multiple tables into 1 single entity, then have EF automagically update the multiple tables when that one edit is saved back to the data context
Edit
Is there a way of mapping 1 entity to second, if the first entity has the primary key of the second and the second entity doesnt have any key relating back to the first?