ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking

Viewed 1189

I have created a default ASP Net Core MVC web app with Individual User Accounts. I added a custom UserID INT field to the AspNetUsers table and linked this as a foreign key to all my other custom tables so I can track what users inserted/updated records in my database. I did this as I prefer using INT fields for primary keys. In this scenario everything is working fine.

I am now thinking of using an external identity provider such as Azure Active Directory however I cannot work out how I would link a user in Azure AD (or any other identity provider) to my local database tables to maintain the user id foreign key constraints. From all my research I cannot find any articles for this scenario.

How can I link user info from an external identity provider to my local database tables? I am worried that I might need to double handle the user account management in both the external identity provider and my local AspNet user tables to maintain the foreign keys with my other custom tables which seems crazy.

Perhaps i'm missing something obvious or my approach is all wrong so if there is a better alternative for tracking who did what in my database tables for an ASP Net Core web application using an external identity provider I would happily adopt it.

1 Answers
Related