The instance of entity type 'IdentityUserLogin<string>' cannot be tracked because another instance with the same key value for {'LoginProvider', 'ProviderKey'} is already being tracked

Questions: How do you solve: The instance of entity type 'IdentityUserLogin<string>' cannot be tracked because another instance with the same key value for {'LoginProvider', 'ProviderKey'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.


Solution: This means that the external Login Provider has stored a Key Pair Value that you currently have in your database. For Example user is trying to log in with Google and the User had logged into your application at some point and the application stored the Key related to the user. The Application would then throw an error that the Key is already in the database.

- Best way to resolve this issue is by finding a Kay related to the User and then modifying it or delete it.

1. First get the ProverKey in your code
    var providerKey = info.ProviderKey.ToString()
2. When you get the providerKey when debugging, go to your LoginProvider User Table and search for that providerKey
3. Remove it or modify it so it does not become duplicate

.Net 5 Database Context .NET 5 published

Was this page helpful?

Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
Login to Continue




© 2020 - ErnesTech - Privacy