-
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
Improve documentation and exception message for .Navigation() #34780
Comments
it still repros on current main, however if one swaps the order of OwnsMany and Navigation calls in the nested case (i.e. OwnsMany first then Navigation) things work just fine: protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Owner>(b =>
{
b.Navigation(e => e.Items).HasField("_ownedItems");
b.OwnsMany(e => e.Items, b =>
{
b.WithOwner().HasForeignKey(e => e.OwnerId);
b.HasKey(e => e.Id);
// If you comment this out, migrations work.
b.Navigation(e => e.Items).HasField("_ownedItems");
b.OwnsMany(e => e.Items, b =>
{
b.WithOwner().HasForeignKey(e => e.OwnerId);
b.HasKey(e => e.Id);
});
});
});
} |
This is expected, the relationship needs to be configured (with |
Ok, thanks, @AndriySvyryd. So And this xmldoc for
Is there an analyzer for this, btw? |
@AndriySvyryd , by the way, I see that order: |
It does if the navigation is not discovered by convention. E.g. it has |
@AndriySvyryd Will public property of any type implementing |
Yes, in most cases |
File a bug
I am getting
Navigation was not found.
exception when creating a migration.Include your code
See this repository
Here are the mapped classes:
And here's the mapping part:
While first
b.Navigation(e => e.Items).HasField("_ownedItems");
works fine. The one for nested collection causes migration to fail.Include verbose output
Include provider and version information
EF Core version: 8.0.8
Database provider: does not matter. Fails both for SQL Server and Postgres.
Target framework: (e.g. .NET 8.0)
Operating system: Windows 11 Pro 23H2
IDE: Visual Studio 2022 17.12 Preview 2.1
The text was updated successfully, but these errors were encountered: