ModelBuilder: stackoverflow for may be invalid relationship via fluent api
See original GitHub issueModel
public class Blog
{
public int Id { get; set; }
public Blog MyBlog { get; set; }
public Blog InverseBlog { get; set; }
}
// Write following in OnModelCreating method
modelBuilder.Entity<Blog>().HasOne(e => e.MyBlog).WithOne(e => e.InverseBlog).HasForeignKey<Blog>(e => e.Id);
Watch it 🔥
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Can not set up one to many relationship with EF fluent API
I am trying to configure a one to many relationship using EF Core via fluent api and i keep getting the following error...
Read more >What a very bad day at work taught me about building ...
No one agreed with this policy, and they made it known over seemingly hundreds of ... If we write wrong code, we just...
Read more >Fluent API - Relationships - EF6
Fluent API - Relationships in Entity Framework 6. ... You can then configure foreign key properties by using the HasForeignKey method.
Read more >Ef core exclude navigation property. NET Web API to explicitly ...
I have been able to use fluent API to get this set up provided that the ... I know using IEnumerable<User> AllCreatedUsers property...
Read more >Ef core seed large data. Where(m => m. Your migration can ...
You can do this using DbUp, ef migrations, or similar. ... HasData fluent API is part of the so called EF Core Model...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Workaround: If you are scaffolding from an existing database you can use the query from https://github.com/aspnet/EntityFrameworkCore/issues/9462#issuecomment-325388454 to find the redundant FKs that cause this issue. Then either drop them or comment out the corresponding navigation properties.
Hi @AlanMacdonald, @Nyami, @dabasejumper, @tandradeflorencio. We are gathering information on the use of EF Core pre-release builds. You reported this issue shortly after the release of 2.0.0 RTM. It would be really helpful if you could let us know:
Thanks in advance for any feedback. Hopefully this will help us to increase the value of pre-release builds going forward.