-
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
2.2.6 migrations fail after upgrade to 3.0.0 if model has nested owned types #18183
Comments
It's probably not the best workaround but after getting that error I found the v2.2.0 b2.HasOne("EFCoreOwnTypesTest.Buyer")
.WithOne("Address")
.HasForeignKey("EFCoreOwnTypesTest.Address", "BuyerOrderId")
.OnDelete(DeleteBehavior.Cascade); to b2.WithOwner()
.HasForeignKey("BuyerOrderId"); |
@dandenton |
@AndriySvyryd Should the breaking changes document be updated to state that all existing migrations also need to be updated and not just the current configuration? The way I read the document was that only your current configuration would need to change. I assumed that a migration's |
@mcetkovsky I forgot to mention that when upgrading to 3.0 you need to close and reopen VS to load the new EF tools |
Yes. The error always occurs even after an update/restart. It also happens when you script migrations using the 3.0 tool against migrations created with version 2.2.6-servicing-10079. |
@AndriySvyryd The 3.0 tools seemed to be loaded even without restarting VS. However, they were still using no-longer-present deleted files from the deleted Migrations folder until the VS was restarted. |
Add-Migration
fails after upgrading a project from 2.2.6 to 3.0.0 if the project contains nested owned entities.Steps to reproduce
What steps can we follow to reproduce the issue?
Add-Migration InitialMigration
EFCoreOwnTypesTest.csproj
and replacenetcoreapp2.2
withnetcoreapp3.0
and all2.2.6
with3.0.0
OrderConfiguration.cs
and replace allReferenceOwnershipBuilder
withOwnedNavigationBuilder
Add-Migration -v AfterUpgrade
The second
Add-Migration
call fails complaining thatThe type 'EFCoreOwnTypesTest.Buyer' cannot be configured as non-owned because an owned entity type with the same name already exists.
.(stack trace bellow)
Further steps shows that the exception is not thrown if migrations are generated directly using .NET Core 3.0, i.e. the exception is specific to upgrade scenarios only. However, there seems to be an additional cache-like issue affecting the steps.
Add-Migration -v CleanMigration
The third
Add-Migration
call fails complaining thatThe type 'EFCoreOwnTypesTest.Buyer' cannot be configured as non-owned because an owned entity type with the same name already exists.
.(stack trace bellow)
Remember, the project is now based on .NET Core 3.0
Add-Migration -v CleanMigration
The
Add-Migration
command now succeeds even the code and the configuration is the same as when performing the step 6.I'm not sure whether this step 6 vs step 9 difference in results is a separate issue or not.
Stack trace
Further technical details
EF Core version: 3.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: NET Core 3.0
Operating system: Windows 10 1903
IDE: Visual Studio 2019 16.3.2
EFCoreOwnTypesTest.zip
The text was updated successfully, but these errors were encountered: