You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I update my code from ef6 to ef7.
In my ef6 code I map my JSON column using custom Conversion method.
Now I want to use the new ef7 feature ToJson but I encountered a problem,
If I set ToJson configuration after the property configuration, I get this error:
InvalidOperationException: The property or navigation 'MyJsonColumn' cannot be added to the entity type 'MyEntity' because a property or navigation with the same name already exists on entity type 'MyEntity'.
Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.AddNavigation(MemberIdentity navigationMember, ForeignKey foreignKey, bool pointsToPrincipal)
If I set ToJson configuration before the property configuration like this:
InvalidOperationException: 'MyJsonColumn' cannot be used as a property on entity type 'MyEntity' because it is configured as a navigation.
Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.Property(Type propertyType, string propertyName, MemberInfo memberInfo, Nullable<ConfigurationSource> typeConfigurationSource, Nullable<ConfigurationSource> configurationSource)
I search in your tests here and here but I didn't find anything.
I use IEntityTypeConfiguration for my entities configurations.
My question is:
How can I configure HasMaxLength or HasDefaultValueSql or other property configuration to my Entity column?
Hi,
I update my code from ef6 to ef7.
In my ef6 code I map my JSON column using custom Conversion method.
Now I want to use the new ef7 feature
ToJson
but I encountered a problem,My EF6 configuration was:
Now my EF7 configuration is:
If I set
ToJson
configuration after the property configuration, I get this error:If I set
ToJson
configuration before the property configuration like this:I get this error:
I search in your tests here and here but I didn't find anything.
I use
IEntityTypeConfiguration
for my entities configurations.My question is:
How can I configure
HasMaxLength
orHasDefaultValueSql
or other property configuration to my Entity column?EF Core version: 7.0.0
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 7.0)
Operating system: Win 11
IDE: Visual Studio 2022 17.4.2
The text was updated successfully, but these errors were encountered: