-
-
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
I am using Per-Tenant Data with identity but the AddLoginAsync from Identity library won't work #926
Comments
I'm running into the same issue. @AndrewTriesToCode do you have any advice? 🙏 |
Hi, that particular entity is a little different from the others and I'm not sure why. First thing I recommend to try is to set the TenantNotSetMode for your context to I will look into this further -- let me know if that setting helps. |
Hi Andrew, thank you for the suggestion and I appreciate all the work you've put into this project. I've tried overriding the
|
That would have been too easy huh? Hm, are you using the default Identity UI? Do you have the external login page scaffolded out by any chance and if so can you copy paste it here? |
Yes I'm just using the default scaffolded identity code for
|
Ok I think I have a solution for you. Create a class:
Then in your context setup do something similar to this:
And set This will have the field default to |
Hi Andrew, Thank you very much for the potential solution, however I feel like I'm missing something obvious. I don't seem to have access to
As a side note, should the EDIT: I can call
However, if I do that then I receive the following error:
EDIT 2: If I flesh this out a bit more and add the keys like so
Then I run into
As someone not very familiar with non-tyical EF usage I'm not sure if I'm digging the right way through this rabbit hole 😅 |
Hi, you figured it out before I could answer. For the primary Key thing -- I didn't specify it but I call I have edited the above with the corrections. And you are doing great, this is a great learning experience for you and I both. I figured this out a few years ago and had to to figure it out now. Maybe it'll stick this time. I will probably build this right into the library for the next release. |
Ahh. I left out the call to Good news and bad news - I can now get past that issue but run into this immediately afterwards:
in
|
Haha ok in the generator change that property to false instead of true. Sorry I’m not on my computer so it’s been hit or miss… |
🤦 Oh I should read the code I paste more carefully I didn't even notice that property. Changing to false appears to have worked! Now when I log in it seems to log me back out immediately, but I believe thats a seperate issue somewhere that's probably my fault. Thank you again Andrew, appreciate the guidance. |
Hello,
I am wondering if you can suggest a fix for this issue:
I am using Per-Tenant Data with identity, And as the documentation describes I can see the TenantID added as a primary key to the AspNetUserLogins table. However, when I try to add a login:
result = await UserManager.AddLoginAsync(user, externalLoginInfo);
I get this exception:
'System.InvalidOperationException': Unable to track an entity of type 'IdentityUserLogin<string>' because its primary key property 'TenantId' is null.
The text was updated successfully, but these errors were encountered: