-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
System.InvalidOperationException: 'Unable to track an entity of type 'IdentityUserLogin<string>' because its primary key property 'TenantId' is null.' #881
Comments
Thanks I am looking into it. Does this happen during the third party sign in login flow or are you inserting into the table somewhere else in your code? |
Yes, In application I am implementing google and Microsoft SSO login, From UI side I have received Google token, so first I have check token is verified or not, if token is verified then check Login exist or not with var result = await _userManager.FindByLoginAsync(loginProvider,providerKey); If no login exist then inserting data in AspNetUser table then AspNetUserLogin table. but in AspNetUser data inserted successfully but AspNetUserLogin cause issue. |
Are you using Asp.net Identity? Also can you please post what your Finbuckle setup looks like in your program.cs file? |
Yes I have use Asp.net identity. program.cs file code : ----------Program.cs----------
----------ServiceCollectionExtensions.cs----------
----------MultiTenantStoreDbContext.cs----------
----------SubscriptionManagmentDbContext.cs----------
|
Thanks. I don’t see any issues with this code. Where exactly in your app is |
I have created a repository called IdentityRepository, which I am currently using. Repository Code:
|
Is your identity repository registered in DI? What is the lifetime? The user manager internally will have a user store which internally uses your dbcontext which was instantiated for the current tenant. If you also inject |
I have registered the identity repository in dependency injection with a scoped lifetime. However, I cannot find |
Discussed in #879
Originally posted by MayurPatel-BlobStation October 4, 2024
"When I attempt to insert data into the AspNetUserLogin table, I encounter the following error: System.InvalidOperationException: 'Unable to track an entity of type 'IdentityUserLogin' because its primary key property 'TenantId' is null.'. However, inserting data into the AspNetUser table works correctly."
var userResult = await _userManager.FindByEmailAsync("abc@gmail.com");
var result = await _userManager.AddLoginAsync(userResult, externalLoginInfo);
The text was updated successfully, but these errors were encountered: