-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SaveChanges with a UserManager does not record username #128
Comments
https://github.com/bilal-fazlani/tracker-enabled-dbcontext/wiki/4.-Username Configure the username using above method. Ps: I am just hoping that you can somehow pass the dbcontext while creating Let me know. On Wed 26 Oct, 2016 7:33 pm jono-royle, [email protected] wrote:
|
Hi, thanks for your help. We are using the SaveChangesAsync() method for both editing existing users and creating new users. Do you know why these two might be different? |
Do You Want Know About Differnce Between SaveChangesAsync() And SaveChanges() ? |
No sorry, both our EditUser method and CreateUser method are using the SaveChangesAsync() method, but it is only working correctly in the EditUser method. |
Show me your code |
This is the code we have to create a new user. As you can see we call await _db.SaveChangesAsync(). We have other methods which edit users in the same class that also call SaveChangesAsync(), and those work as expected, but this doesn't. We configure the username in the class constructor as you suggested |
Show me |
Creation of _db and username configured in class constructor:
|
_db is created here:
|
How UserManager is created:
|
Your context class name is |
Anyways,
|
Sorry the DBContext DbContext was a typo, I changed the type names to remove some application specific jargon
|
Maybe the cause for username being null is that there is no HttpContext available in the constructor of the controller. So, User is null and therefor no username is written in the logging? |
Hi,
We are using an ASP.NET UserManager in our project. When we SaveChanges with the UserManager, it isn't using SaveChanges(userName) from the TrackerIdentityContext in your project, so we end up with the UserName column reading NULL for these changes in the AuditLog table.
Is there a way to solve this problem while still using the UserManager?
Thanks
The text was updated successfully, but these errors were encountered: