简体   繁体   中英

Entity Framework One to Many, Many to Many relationship

I'm building an api using asp.net web api for an application that needs to track all the activities performed by users. So in every table I need to have createdUser and updatedUser field with their dates. But I faced some challenges on how to go about.

Here are my concerns:

  1. How can I have that in the User table itself? Which type of relationship do I need for that?

  2. I have a privilege table than can be created by required users. What type of relationship can I have between the Privilege and the User table?

I'm new to Entity Framework so I need some guides. Please can anyone be very kind to provide some help. Thank you

  1. I don't think u wil need to have that logic in the user table itself. U can add extra colomn's to each table with CreUser,CreDate, LModUser, LModDate. Or U can create an extra table like Entity_ID, Record_ID, User_ID, ModDate, IsCreated. (or with other logic)

  2. search for many to many relations on google. or:

How to create a many-to-many mapping in Entity Framework?

this is a nice tutorial for all kind of relationships in EF for core http://www.learnentityframeworkcore.com/configuration/one-to-many-relationship-configuration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM