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 am declaring a property of type IReadOnlyCollection<string> and wanted to store it as a string array in the CosmosDB, I am getting the following error:
Unhandled exception. System.InvalidOperationException: The property 'Book.Tags' is of type'IReadOnlyCollection<string>' which is not supported by the current database provider. Either change the property CLR type, or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore'in'OnModelCreating'.
at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.ValidatePropertyMapping(IModel model, IDiagnosticsLogger`1 logger) at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger) at Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal.CosmosModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger) at Microsoft.EntityFrameworkCore.Infrastructure.ModelRuntimeInitializer.Initialize(IModel model, Boolean designTime, IDiagnosticsLogger`1 validationLogger) at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime) at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime) at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model() at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__8_4(IServiceProvider p) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
In the configuration file for the Book entity, I used the following:
The error is gone if I either use a List<string> with no backing field or use a conversion for converting IReadOnlyCollection<string> to string[].
Provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Target framework: net6.0
Operating system: mac OS Monterey
IDE: RIder 2022
PS: You could find an application that reproduce the error in this repository/branch. When cloning the application, make sure the reproduce/efcore-error branch is checked out. The Main branch already has the conversion included.
The text was updated successfully, but these errors were encountered:
@shahabganjiIReadOnlyCollection is not supported because it's too generic for use to map appropriately. Use IReadOnlyList or IReadOnlyDictionary instead.
Related Issue: #25344
I am declaring a property of type
IReadOnlyCollection<string>
and wanted to store it as a string array in the CosmosDB, I am getting the following error:In the configuration file for the
Book
entity, I used the following:Even when I change the last line to
The error is gone if I either use a
List<string>
with no backing field or use a conversion for convertingIReadOnlyCollection<string>
tostring[]
.Provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Target framework: net6.0
Operating system: mac OS Monterey
IDE: RIder 2022
PS: You could find an application that reproduce the error in this repository/branch. When cloning the application, make sure the
reproduce/efcore-error
branch is checked out. TheMain
branch already has the conversion included.The text was updated successfully, but these errors were encountered: