We are upgrading our asp.net core app (which runs on the full .net framework) from asp.net 2.0 / ef core 2.0 to asp.net 2.1 / ef core 2.1. I'm surprised how much of a headache it is for a minor update...
Anyway, after upgrading to 2.1 and adding a migration without any code changes to the model, EF creates a migration to move a owned type that we use (the only one) to a separate table. Why? The [documentation][1] states otherwise:
When using relational databases, by convention owned types are mapped to the same table as the owner.
We can fix the issue by adding a ToTable() and passing the name of the parent entity, but we don't understand why this is required in the first place.
Before:
builder.Entity<Chart>().OwnsOne(c => c.BarLineOptions);
After:
builder.Entity<Chart>().OwnsOne(c => c.BarLineOptions).ToTable("Chart");
We also attempted to remove this fluent configuration with the new OwnedAttribute but it causes the same problem so we really need the fluent config to call ToTable()
Update: If we don't create the migration, we get an exception when starting the app saying the table BarLineOptions doesn't exist