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
- Fix to #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' Problem was that we made some assumptions when compiling in... — committed to dotnet/efcore by maumar 7 years ago
- Fix to #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' Problem was that we made some assumptions when compiling in... — committed to dotnet/efcore by maumar 7 years ago
- Fix to #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' Problem was that we made some assumptions when compiling in... — committed to dotnet/efcore by maumar 7 years ago
- Fix to #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' Problem was that we made some assumptions when compiling in... — committed to dotnet/efcore by maumar 7 years ago
- Fix to #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' Problem was that we made some assumptions when compiling in... — committed to dotnet/efcore by maumar 7 years ago
- [2.0.1] - Fix #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' - Modify QuerySourceTracingExpressionVisitor so that... — committed to dotnet/efcore by anpete 7 years ago
- [2.0.1] - Fix #9551 - Expression of type 'System.Object' cannot be used for parameter of type 'Microsoft.EntityFrameworkCore.Metadata.IEntityType' - Modify QuerySourceTracingExpressionVisitor so that... — committed to dotnet/efcore by anpete 7 years ago
- Add quirks for #9551 — committed to dotnet/efcore by anpete 7 years ago
- Revert "Add quirks for #9551" This reverts commit 9b3a5140214c10feec5a0ef40b8a94dfb3fec8af. — committed to dotnet/efcore by smitpatel 7 years ago
@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 therel/2.0.1
branches ready please port the commit to that branch.@grokky1