-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add option to reverse engineer to string-based model builder calls #21489
Comments
@dapowers87 At what point in your application does the stack overflow occur? |
During the ToList, ToListAsync, FirstOrDefault, etc... (or anything like it) call. |
@dapowers87 Is it possible to attach code that reproduces the issue? |
It would simply be something like:
It appears that the index that I originally posted is the reason behind the SO as it went away when I removed it. |
@dapowers87 - Can you share the entity class on which that index is defined so I can create a repro code? |
Here is the Invoice class. One more bit of information, I found the stack overflow occurs on any DbSet in the context, as they all call that OnModelCreating function it seems.
|
@dapowers87 - Stackoverflow must be happening during HasIndex call on OnModelCreating. |
Right - I've come to that conclusion as well. Is there any idea why it is happening, though? |
Likely this #14702 (comment) |
I think you would have been "saved" by this fix #7665 (which was in 2.0, but not in 2.1 to 3.1 - now back in 5.0) |
Creating a lambda takes space on the stack. Replacing the calls with the |
@ErikEJ Is there any way to tell for sure this was a hypothetical index? |
No - but it is likely, given the index name. |
@AndriySvyryd @bricelam I can't find an existing issue about reverse engineering using string args rather than lambdas. Should we consider it part of #4038, or should it have its own issue? |
Is there anyway to accomplish using scaffolding? This is how all of this indexes were created in the first place. |
@ajcvickers Seems we only have one for the snapshot: #18620. We could repurpose this one. |
@dapowers87 Not currently--putting this issue on the backlog to consider doing it in the future. However, it's likely that you are hitting #20705, which is fixed in the EF Core 5.0 preview. |
@dapowers87 Check out my EFCore.TextTemplating sample for a good starting point for customizing the generated code. The EF Core Power Tools also let you use Handlebars templates to customize the code |
Large numbers of lambda expressions can cause issues with stack use. Adding an option to use the string-based API instead would help with this, and potentially also be faster in model building.
Original issue
I am running dotnet version 3.1.301 on Mac OS Catalina. There are a couple hundred indices on one DbSet that was created when scaffolded. I found more than one HasIndex that caused the issue. Here is one:
The issue does not show itself when running the same call in Windows 10 or Docker's dotnet/core/aspnet:3.1-alpine.
Removing all HasIndex's is a workaround for now.
The text was updated successfully, but these errors were encountered: