efcore: Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType'

Since updating to v2 I now get the following exception from one of my unit tests:

System.ArgumentException : Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' of method 'Void StartTracking(System.Object, Microsoft.EntityFrameworkCore.Metadata.IEntityType)'
Parameter name: arg1

In order to get the test to pass I have had to change:

var projects = this.context.Projects
                        .Include(p => p.Windfarm)
                        .Include(p => p.Turbines)
                        .Where(p => p.Windfarm.ClientId == clientId && p.IsActive)
                        .GroupBy(g => g.WindfarmId)
.Select(s => s.OrderByDescending(o => o.DateStarted).FirstOrDefault())
                        .ToList();

to the following:

var activeProjects = this.context.Projects
                        .Include(p => p.Windfarm)
                        .Include(p => p.Turbines)
                        .Where(p => p.Windfarm.ClientId == clientId && p.IsActive)
                        .GroupBy(g => g.WindfarmId).ToList();

            var projects = activeProjects.Select(s => s.OrderByDescending(o => o.DateStarted).FirstOrDefault())
                        .ToList();

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 20 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@paillave ideally, file a new issue with the info and reference this one.

@paillave can you provide full code listing? (i.e. entities and dbcontext)

This patch bug is approved for the 2.0.x patch. Please send a PR to the feature/2.0.1 branch and get it reviewed and merged. When we have the rel/2.0.1 branches ready please port the commit to that branch.

@grokky1

  • NuGet
    • RTM Patch releases (e.g. 1.1.0 -> 1.1.1) containing important bug fixes and no new features.
    • RTM Point releases (e.g. 1.0.x -> 1.1.0) containing bug fixes and new non-breaking features
    • RTM Major releases (e.g. 1.x.x -> 2.0.0) containing bug fixes, new features, and possibly breaking changes
    • Pre-releases in each of these categories, although we haven’t yet done any pre-releases on NuGet for patch releases due to logistical issues on our side.
  • MyGet
    • Nightly builds, C.I. builds, etc. (That is, not releases)