-
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
The type cannot be marked as owned because a non-owned entity type with the same name already exists #18092
Comments
Intentional breaking change as per #9148 @AndriySvyryd - Do you want to add this to breaking changes doc? |
@codehunter13 - I could not see where you are configuring |
I have the same error after upgrade |
That's my code
|
@codehunter13 The exception was introduced to catch configuration like that. It might have worked for your model, but in general it's not supported and could've let to unexpected behavior. |
Looks like i solved this too by changing configuration. Thanks.
|
@AndriySvyryd Yep, this is a breaking change. And I can change code, but it's not cool that I have to change ContextModelSnapshot, i.e. I have no chance for rollback now as I understood.
modelBuilder.Entity("Connect.Device.BusinessModel.Entities.Organization", b =>
{
b.OwnsOne("Connect.Device.BusinessModel.Values.OrganizationAddress", "Address", b1 =>
{
b1.Property<Guid>("OrganizationId");
b1.Property<string>("City")
.HasMaxLength(255);
b1.Property<int>("CountryId");
b1.Property<string>("PostalCode")
.HasMaxLength(50);
b1.Property<string>("Street")
.HasMaxLength(255);
b1.HasKey("OrganizationId");
b1.HasIndex("CountryId");
b1.ToTable("OrganizationAddress");
b1.HasOne("Connect.Device.BusinessModel.Entities.Country")
.WithMany()
.HasForeignKey("CountryId")
.OnDelete(DeleteBehavior.Restrict);
b1.HasOne("Connect.Device.BusinessModel.Entities.Organization")
.WithOne("Address")
.HasForeignKey("Connect.Device.BusinessModel.Values.OrganizationAddress", "OrganizationId")
.OnDelete(DeleteBehavior.Cascade);
b1.OwnsOne("Connect.Device.BusinessModel.Values.House", "House", b2 =>
{
b2.Property<Guid>("OrganizationAddressOrganizationId");
b2.Property<string>("Number")
.HasColumnName("HouseNumber")
.HasMaxLength(50);
b2.Property<string>("Suffix")
.HasColumnName("HouseNumberSuffix")
.HasMaxLength(50);
b2.HasKey("OrganizationAddressOrganizationId");
b2.ToTable("OrganizationAddress");
// line 3093
b2.HasOne("Connect.Device.BusinessModel.Values.OrganizationAddress")
.WithOne("House")
.HasForeignKey("Connect.Device.BusinessModel.Values.House", "OrganizationAddressOrganizationId")
.OnDelete(DeleteBehavior.Cascade);
});
}); And org configuration now looks like this: public void Configure(EntityTypeBuilder<Organization> builder)
{
builder.ToTable("Organization");
builder.Property(_ => _.Version)
.IsConcurrencyToken()
.HasDefaultValue(0);
builder.OwnsOne(m => m.Address, b =>
{
b.WithOwner().HasForeignKey("OrganizationId");
b.ToTable("OrganizationAddress");
b.HasOne<Country>()
.WithMany()
.HasForeignKey(m => m.CountryId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
b.OwnsOne(
m => m.House,
bld =>
{
bld.Property(m => m.Number).HasColumnName("HouseNumber");
bld.Property(m => m.Suffix).HasColumnName("HouseNumberSuffix");
});
});
builder.OwnsOne(
m => m.ExternalIds,
act => { act.ToTable("OrganizationExternalIds"); });
builder.OwnsOne(
m => m.ExternalReferences,
act => { act.ToTable("OrganizationExternalReferences"); });
builder.Property(m => m.SendInvoiceTo).HasDefaultValue(FulfilmentPartnerSendsInvoiceTo.OurCompany);
} |
Upgraded to ef core 3.0 and OwnsMany calls are giving the following error:
The entity:
The valueobject:
This was working in the previous ef core version
The text was updated successfully, but these errors were encountered: