efcore: Debugger crash with Microsoft.EntityFrameworkCore.Proxies
Describe what is not working as expected. I’m using Microsoft.EntityFrameworkCore.Proxies to lazy load my navigation properties but I can’t debug my objects anymore. When I try to evaluate them in the debugger the debugger just crashes with the following exception - see also https://gist.github.com/dvdbot/df1673453545a0ddb44148cc17950d4b for larger stacktrace
terminate called after throwing an instance of 'PAL_SEHException'
The target process exited with code 0 while evaluating the function 'System.Linq.SystemCore_EnumerableDebugView<T>.Items.get'.
If the problem happens regularly, consider disabling the Tools->Options setting "Debugging->General->Enable property evaluation and other implicit function calls" or debugging the cause by evaluating the expression from the Immediate window. See help for information on doing this.
The program '[707] dotnet' has exited with code 0 (0x0).
The program 'dotnet' has exited with code 0 (0x0).
Piece of code
var a = _context.Orders.Include(x => x.CaseRows).Include(x => x.ComponentRows);
var t = a.SelectMany(
o => o.CaseRows.GroupBy(
cR => cR,
cR => cR.Count,
(row, counts) =>
new
{
productId = row.ProductId,
articleCode = row.ArticleCode,
description = (row.Product == null) ? null : row.Product.Description,
mainGroup = (row.Product == null) ? MainGroup.Case : row.Product.MainGroup,
totalCount = counts.Sum()
}
).Concat(
o.ComponentRows.GroupBy(
cR => cR,
cR => cR.Count,
(row, counts) =>
new
{
productId = row.ProductId,
articleCode = row.ArticleCode,
description = (row.Product == null) ? null : row.Product.Description,
mainGroup = (row.Product == null) ? MainGroup.Component : row.Product.MainGroup,
totalCount = counts.Sum()
}
))).OrderByDescending(c => c.totalCount).Take(lastAmount);
return Ok(t);
I’ve got a breakpoint on the last line
return Ok(t)
The debugger crashes when I open t
and then try to open the Results View
This thing:
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
var a = _context.Orders.Include(x => x.CaseRows).Include(x => x.ComponentRows);
var t = a.SelectMany(
o => o.CaseRows.GroupBy(
cR => cR,
cR => cR.Count,
(row, counts) =>
new
{
productId = row.ProductId,
articleCode = row.ArticleCode,
description = (row.Product == null) ? null : row.Product.Description,
mainGroup = (row.Product == null) ? MainGroup.Case : row.Product.MainGroup,
totalCount = counts.Sum()
}
).Concat(
o.ComponentRows.GroupBy(
cR => cR,
cR => cR.Count,
(row, counts) =>
new
{
productId = row.ProductId,
articleCode = row.ArticleCode,
description = (row.Product == null) ? null : row.Product.Description,
mainGroup = (row.Product == null) ? MainGroup.Component : row.Product.MainGroup,
totalCount = counts.Sum()
}
))).OrderByDescending(c => c.totalCount).Take(lastAmount);
return Ok(t);
Further technical details
EF Core version: 2.2.0 Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Windows 10 Pro Insiders (build 18305.1003) IDE: Tried Visualstudio 2017 (15.9.4 Preview 1.0) and 2019 (16.0.0 Preview 1)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (8 by maintainers)
@Cooksauce I’m following up on the expectations for the microsoft/dotnet repo.