Here is my scenario (tables):
Departments
====================
Id (int)
Name (varchar)
Employees
====================
Id (int)
Name (varchar)
EmployeesDepartmentXREFs
====================
EmployeeId (int)
DepartmentId (int)
When I import these 3 tables into EDMX model, I get 2 entities: Employee and Department. Entity Employee has navigational property Departments and entity Department has navigational property Employees.
And this is all fine. I actually like it this way.
But, problem starts when I want to add more fields in the XREF table, for example, I would like to have DateCreated, UserId fields to record when change is made and by who. If I add these two fields in XREF table, then my EDMX model will show 3 entities instead of two. It is not big issue, but since I am already done with coding, I am sort of looking for easy solution (to avoid coding).
Question: Is it possible to add new fields into XREF (cross reference) table and to keep only two entities? If yes, how would I update my datetime and userid information?
I assume that XREF entity has to be present in order to be able to update it (with date and user id), but I really like having navigational properties: Departments and Employees, versus having navigational properties EmployeesDepartmentXREFs.
Is there a middle ground for this? What is the best practice?
Thanks.