-
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
Model Building: StackOverflowException when two properties share the same foreign key #6115
Comments
@ntsekouras Yes. Are you seeing an error? If so, please provider error, stack trace, and full repro code. |
Closing as we have answered the question. If you see an error, reply with details and we will reopen. |
We get a big exception "dotnet has stopped working" dotnet : Process is terminated due to StackOverflowException.
|
The other 2 classes are like this
We also set up fluent API like this
|
StackOverflow in latest codebase too. Setting |
Is there a workaround for v1.0 of efcore? |
@ntsekouras You would need to remove the annotations, configure one of the relationships using Fluent API and the other one using Model API: modelBuilder.Entity<FileRecord>().HasOne(f => f.Decision).WithMany().HasForeignKey(f => f.EntityId);
modelBuilder.Entity<FileRecord>().Ignore(f => f.Invitation);
var fileRecordEntityType = modelBuilder.Entity<FileRecord>().Metadata;
var invitationEntityType = modelBuilder.Entity<Invitation>().Metadata;
fileRecordEntityType.AddForeignKey(
new[] { fileRecordEntityType.FindProperty("EntityId") },
invitationEntityType.FindPrimaryKey(),
invitationEntityType)
.HasDependentToPrincipal(typeof(FileRecord).GetTypeInfo().GetDeclaredProperty("Invitation")); |
Can i have two properties with the same foreign key?
EF Core version: 1.0.0
Operating system: Win10 64
Visual Studio version: VS2015
The text was updated successfully, but these errors were encountered: