Entity framework: adding information to relational tables but keeping the EF object format

If I have 3 tables:

Client
CustID
Name
Email


ListID
Title List

ClientsLists
CustID
ListID

Entity Framework grabs customer lists very easily.

db.Customers.FirstOrDefault(c => c.Name == "Bob").Lists

      

I need to store the creation timestamp of the relational table so I can see when the client was added to the list.

I don't want to add the column timestamp to the relational table because it will work with the intuitive LINQ functionality since the Customer.Lists

table appears instead CustomersLists

.

I have about 12 tables that should have this timestamp, most of which don't have many, many relationships. Just fishing to see if anyone has a really good solution that I am missing.

+3


source to share


1 answer


Do not match timestamp

in EF mapping. And set the default value for the column timestamp

at the database level: getDate()

. It will set it to the current "datetime" on the insert.



+1


source







All Articles