efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

2.1.0-rc1: System.InvalidOperationException: The property 'BaseDockerModel.Labels' is of type 'IDictionary<string, string>' which is not supported by current database provider.

Open m-barthelemy opened this issue 8 years ago • 3 comments

I just upgraded to 2.1.0-rc1. I have models that have a public IDictionary<string, string> Labels { get; set; } property.

I was previously using 2.0.0 and this was transparently and automatically mapped to hstore columns, provided the extension was enabled on the Posgtres server. Which was a very good surprise by the way :-)

Now I'm getting the following error:

gil.main_1               | System.InvalidOperationException: The property 'BaseCustomerModel.Labels' is of type 'IDictionary<string, string>' which is not supported by current database provider. Either change the property CLR type or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
gil.main_1               |    at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.PropertyMappingValidationConvention.Apply(InternalModelBuilder modelBuilder)
gil.main_1               |    at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnModelBuilt(InternalModelBuilder modelBuilder)
gil.main_1               |    at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.OnModelBuilt(InternalModelBuilder modelBuilder)
gil.main_1               |    at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.Validate()
gil.main_1               |    at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
gil.main_1               |    at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.<>c__DisplayClass5_0.<GetModel>b__1()
gil.main_1               |    at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
gil.main_1               |    at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
gil.main_1               |    at System.Lazy`1.CreateValue()
gil.main_1               |    at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
gil.main_1               |    at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
gil.main_1               |    at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
gil.main_1               |    at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__7_1(IServiceProvider p)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
gil.main_1               |    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
gil.main_1               |    at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
gil.main_1               |    at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
gil.main_1               |    at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
gil.main_1               |    at Microsoft.EntityFrameworkCore.DbContext.Set[TEntity]()

Any way to get this supported again?

m-barthelemy avatar May 16 '18 14:05 m-barthelemy

Can you please change the type from IDictionary<string, string> to Dictionary<string, string> (the class not the interface)?

Will close this as the expected behavior but am open to discuss if needed.

roji avatar May 16 '18 15:05 roji

@roji Many thanks, that fixed the issue.

m-barthelemy avatar May 17 '18 00:05 m-barthelemy

Unfortunately this is still an issue. I'm not able to use EF Core migration mechanism together with this provider. I've chaged my declaration from IDictionary<,> to Dictionary but it didn't help.

The property 'EntityName.Data' is of type 'Dictionary<string, string>' which is not supported by current database provider. Either change the property CLR type or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

staskolukasz avatar Jun 07 '18 08:06 staskolukasz