-
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
Generated Model Snapshot throws InvalidOperationException #29534
Comments
We are getting the same error, (both with changes, but also with an empty migration) The snapshot now adds "ToTable" with property definitions, that was set on the "Property" before: modelBuilder.Entity("Domain.Entities.Template", b =>
{
b.HasBaseType("Domain.Entities.DynamicFieldListEntity");
b.Property<bool>("IncludeGdpr")
.HasColumnType("bit");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.ToTable("DynamicFieldListEntity", "entities", t =>
{
t.Property("IncludeGdpr")
.HasColumnName("Template_IncludeGdpr");
t.Property("Name")
.HasColumnName("Template_Name");
});
b.HasDiscriminator().HasValue("Template");
}); If we manually change this back in the snapshot, it again works: modelBuilder.Entity("Domain.Entities.Template", b =>
{
b.HasBaseType("Domain.Entities.DynamicFieldListEntity");
b.Property<bool>("IncludeGdpr")
.HasColumnName("Template_IncludeGdpr")
.HasColumnType("bit");
b.Property<string>("Name")
.IsRequired()
.HasColumnName("Template_Name")
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("Template");
}); |
/cc @AndriySvyryd |
Any updates on this? |
@MarounMaroun ths fix for this will be released as part of 7.0.3, in February. In the meantime, you can use the 8.0 daily builds, which contain the fix and are otherwise very stable. |
@roji This means that I must update |
Do we really need to wait 2 months for release cycle? I don't really have much confidence in dev builds being stable when major release introduces such regressions. |
This bug is a serious blocker for us. The workaround requires modifying the snapshot before creating and running migrations. Can't this be released earlier? |
@MarounMaroun Unfortunately not. We are constrained by the .NET release mechanics, which are complicated and long. The January release is already fully complete and cannot be changed. It was also a highly restricted release for internal reasons. As much as we would like to be able to get releases out sooner, we are currently not able to do so. |
This is a major issue for my team. Pretty please, can we get an official fix |
@kastroph this issue has already been fixed, and is in the 7.0.3 milestone - that means the fix will be part of that release, which will be out in about a month. I recommend testing with the latest daily build (which contains the fix), to make sure it works for you. You can also use that build until 7.0.3 is out - our daily builds are very stable. |
@kastroph As all the comments above indicate, the fix is approved for 7.0.3. |
@ajcvickers Tell me please, there is no exact release date for version 7.0.3? |
@Prazdnik Second Tuesday in Feb 2023 |
This issue is still happening on version 7.0.3. Entities with a defined basetype seem to not be inhereting the table name correctly. Edit: just have to rebuild the migrations created in 7.0.2, haven't got it working yet but this seems to be heading in the right direction.. |
@Jadja Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
When migrating from EF6 to EF7, the EF7 generated model snapshot throws
System.InvalidOperationException: Table name must be specified to configure a table-specific property mapping.
when being applied. The generated snapshot also prevents the migration from being removed due to the same exception.The base type is mapped to a custom table name and the expected behavior is that types inheriting from the base table should share the same table name without explicit configuration.
Only the .csproj and nuget libraries were updated to 7, no model or configuration changes were made.
EF Core 6 generated model:
EF Core 7 generated model:
Config for base type:
By adding
builder.ToTable("BalanceLedgerEntries");
in the subtype configuration, the following is generated in the snapshot, which works:The text was updated successfully, but these errors were encountered: