Complex Entity with fields from two or more tables.
Hi,
Am evaluating Entity Framework 4.0 for certain requirements of my project. I have following queries on the same.1) Is there anyway I can create a Custom Entity which can hold fields of two or more different tables? I tried doing this but seems to get compile errors.
2) Can the Custom Entity be directly created from the designer? I tried this but there seems to be a lot of mapping errors.
3) I want to construct a Custom Entity in which one of the property should contain a list of other child tables records. For example :
I have a employee table(Employee) and the address about the employee is stored is a child table(EmployeeAddress) . Each employee can have one or more records in the address table. It's a one to many relationship table(1...*) .
So I want to have a single entity holding a employee details along with his all address details in a property similary to the one given below.
Class Entity
{private long EmpID;
Private string EmpName;
Private List<Address> Address=new List<Address>
}
Please advice/share if any of you guys came across the things I mentioned above.
Thanks,
Arvind
Answers
- 1. Yes. Lots of examples of this, e.g.:
http://msmvps.com/blogs/matthieu/archive/2008/06/20/entity-framework-how-to-use-entity-splitting-with-different-pk.aspx
http://www.robbagby.com/entity-framework/entity-framework-modeling-entity-splitting/
2. Yes. Please provide details of the issues you ran into and we can help.
3. This just sounds like a standard association, if you reverse engineer a database with an FK from EmployeeAddress to Employee, you will get just such a model.
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer byYichun_FengMSFT, ModeratorWednesday, November 11, 2009 1:34 AM
- The product documentation also contains help for the scenarios you describe:
Walkthrough: Mapping an Entity to Multiple Tables
Entity Data Model Tools Tasks
Hope that helps.
-Brian
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer byYichun_FengMSFT, ModeratorWednesday, November 11, 2009 1:34 AM
All Replies
- 1. Yes. Lots of examples of this, e.g.:
http://msmvps.com/blogs/matthieu/archive/2008/06/20/entity-framework-how-to-use-entity-splitting-with-different-pk.aspx
http://www.robbagby.com/entity-framework/entity-framework-modeling-entity-splitting/
2. Yes. Please provide details of the issues you ran into and we can help.
3. This just sounds like a standard association, if you reverse engineer a database with an FK from EmployeeAddress to Employee, you will get just such a model.
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer byYichun_FengMSFT, ModeratorWednesday, November 11, 2009 1:34 AM
- The product documentation also contains help for the scenarios you describe:
Walkthrough: Mapping an Entity to Multiple Tables
Entity Data Model Tools Tasks
Hope that helps.
-Brian
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer byYichun_FengMSFT, ModeratorWednesday, November 11, 2009 1:34 AM


