Hi JJTT-0327,
First, you can try to use reflection to obtain the Id property.
var IdProperty = entity.GetType().GetProperty("Id").GetValue(entity,null);
return (int)IdProperty;
In general, the table in database has auto-generated integer identity Id as primary key.
If your Id is primary key, kuncevic.dev has provided a better solution in this thread you can refer to.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.