Skip to content
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

Appears to not work under EFCore 7 #52

Open
mlockett42 opened this issue Jan 19, 2023 · 1 comment
Open

Appears to not work under EFCore 7 #52

mlockett42 opened this issue Jan 19, 2023 · 1 comment

Comments

@mlockett42
Copy link

Properties linked to related tables via foreign key don't seem to be populated

I have

            var query =
                from u in dbContext.Users
                where u.Id == userId
                select u.IsMaster || (
                    from ur in u.UserRoles
                    where
                        ur.Role.Name == "Developer"
                    select
                        1
                ).Any();

See (https://github.com/mlockett42/EntityFrameworkCoreMock.Fail/blob/master/EntityFrameworkCoreMock.Fail/DemonstrateEFCore7Error.cs#L72)

Which evaluate to false in spite of the face that user with Id == userId is linked to a UserRole which is linked to a Role named "Developer"

I have created this small project to demonstrate this error https://github.com/mlockett42/EntityFrameworkCoreMock.Fail

This works for us in EFCore 6 and 5 and the same version of EntityFrameworkCoreMock.Moq

@nevaldas
Copy link
Contributor

Tried your provided solution - fails in EF Core 5, EF Core 6 and as well as in EF Core 7.
For as long as I am using this project, I don't remember it supporting auto mapping navigational properties. At least we always had that issue.
As well as updating property via navigation won't be reflected by a change in a table (for example, updating role name via user.Role.Name = "foo" (imagine it's a one-to-one relation for simplicity), you won't see that new name in Roles table).
At least these are two mains things that we always had, but came around them by setting those properties ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants