Skip to content

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

@dannythomas13

Description

@dannythomas13

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();

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions