Skip to content
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

StackOverflowException when using same collection navigation twice #23354

Closed
AndriySvyryd opened this issue Nov 17, 2020 · 2 comments
Closed
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported Servicing-approved type-bug
Milestone

Comments

@AndriySvyryd
Copy link
Member

Originally from #23348 (comment):

Yes, my scenario simplified is basically:

class Product {
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<Product> RelatedProducts { get; set; }
}

My OnModelCreating override throws a stackoverflow exception at this statement:

 modelBuilder.Entity<Product>()
                .HasMany(p => p.RelatedProducts)
                .WithMany(p => p.RelatedProducts)
@Tiberriver256
Copy link

Hey @AndriySvyryd looks like your comment may have been deleted but it looks like the StackOverflow only shows up when using the DbContext as a .NET Standard 2.1 class library from a .Net Core 3.1 project.

Here's a repo with a simple solution that produces the error:
https://github.com/Tiberriver256/EFCoreSelfRefrerencingStackOverflowIssueRepro

Thanks for looking into this.

@AndriySvyryd
Copy link
Member Author

@Tiberriver256 Thanks, I was able to repro it

@AndriySvyryd AndriySvyryd modified the milestones: 6.0.0, 5.0.1 Nov 24, 2020
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 24, 2020
@AndriySvyryd AndriySvyryd removed their assignment Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported Servicing-approved type-bug
Projects
None yet
Development

No branches or pull requests

3 participants