Closed mheilimo closed 2 years ago
duplicate of #8817 This bug was fixed in EF Core 2.0 RTM release. Not sure why it is still giving error.
@mheilimo Are you sure you are running against 2.0 RTM? That stack trace looks like the code as it was before the fix.
Actually I used call Update-Package Microsoft.EntityFrameworkCore and it looks that all was updated properly (it wasn't anymore preview what I got) - when I checked dll version it wasn't upgraded properly in one project. After removing and installing it works properly and this issue is also gone. This happen already second time that update-package don't do update properly. Did you see this issue earlier?
So you can close this - thanks for you help!
I my trying (EF core 2.0) to fetch users with Roles from db (my own EF core objects in db), but this fails for some (about 10%) users with this cryptic error - 'The given key was not present in the dictionary' (System.Collections.Generic.KeyNotFoundException) - can you please improve this error message - how I can debug this because there is no info what really failing?
I already checked all similar bugs report earlier and mine is not same than already resolved (I don't have any same name index in db for example). I can't send you full my commercial project to reproduce this, but I do my best to copy paste most important codes here if you will get idea what is wrong and why EF core failing to do what it should do: my call to to get users is this:
I actually investigated it already that it work well without these RoleRelations (ActiveRoleReleations) relations - actually it is enought to have this first 'Users.Include(usr => usr.ActiveRoleRelations)' to get it crash so I guest that problem is in RoleRelation object.
My RoleRelation object is very simple:
MyBaseObject is:
RoleRelations object relations are defined this way:
and all MyObject are defined liked this to get primary key and modified and created datetimes (TEntity is MyObject based class):
This is my role relationTable definition:
Steps to reproduce
If you can't reproduce this issue can you even improve error message that I can find reason for error myself. It can't be that all bug report have to have full big project with it because there is no change to isolate problem from big project if error messages are in this level.
I am more than happy to give you more info if needed to resolve this bug.
Further technical details
EF Core version: 2.0 (latests) Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Windows 10 IDE: Visual Studio 2017 15.3.1 Preview 1.0