Share via

CultureNotFoundException Querying SQL database using EF

Setteidea SRL 0 Reputation points
2024-05-06T10:18:01.0933333+00:00

Hello,

I have a Web App (ASP.NET MVC) with controllers making CRUD operations using EF 6.

Any operation involving the EF context to read data generates the following exception

The Web App is localized in it-IT, setting up ThreadCulture and ThreadUICulture, in Application_Start and setting <globalization culture="it-IT" uiCulture="it-IT" /> in web.config

The error is invariant respect the culture I try to set.

Any idea about this behaviour?

King regards

System.Globalization.CultureNotFoundException: Culture is not supported.

Parameter name: name

ar-DJ is an invalid culture identifier.

at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)

at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)

at System.Reflection.AssemblyName..ctor(String assemblyName)

at System.Data.Entity.Core.Metadata.Edm.MetadataAssemblyHelper.ComputeShouldFilterAssembly(Assembly assembly)

at System.Data.Entity.Core.Common.Utils.Memoizer`2.Result.GetValue()

at System.Data.Entity.Core.Common.Utils.Memoizer`2.Evaluate(TArg arg)

at System.Data.Entity.Core.Metadata.Edm.DefaultAssemblyResolver.<GetAlreadyLoadedNonSystemAssemblies>b__0(Assembly a)

at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()

at System.Data.Entity.Core.Metadata.Edm.DefaultAssemblyResolver.GetAllDiscoverableAssemblies()

at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)

at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)

at System.Data.Entity.Core.Metadata.Edm.MetadataCache.SplitPaths(String paths)

at System.Data.Entity.Core.Common.Utils.Memoizer`2.Result.GetValue()

at System.Data.Entity.Core.Common.Utils.Memoizer`2.Evaluate(TArg arg)

at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetArtifactLoader(DbConnectionOptions effectiveConnectionOptions)

at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions)

at System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()

at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)

at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()

at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()

at System.Data.Entity.Internal.InternalContext.Initialize()

at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)

at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()

at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()

at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()

at System.Linq.Queryable.Where[TSource]

at WebApp.DataModel.DataExtensions.GetDays(DataEntities context)

Developer technologies | ASP.NET | Other
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.