29 May 2014

Entity Framework Error: Parameter name: entitySet

I came across this little error message today and it took me a while to realise it was down to attempting to map a property of type System.Type. The solution for me was to ignore it with [NotMapped].

Hopefully this note will help someone else.

Stack trace:
[ArgumentNullException: Value cannot be null.
Parameter name: entitySet]
   System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.AddEntitySetMapping(DbDatabaseMapping databaseMapping, EntitySet entitySet) +370
   System.Data.Entity.ModelConfiguration.Edm.Services.TableMappingGenerator.Generate(EntityType entityType, DbDatabaseMapping databaseMapping) +95
   System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(DbDatabaseMapping databaseMapping) +311
   System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) +442
   System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +288
   System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +94
   System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +248
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +618
   System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps() +23
   System.Data.Entity.Database.Exists() +40
   Coultard.App.Ui.Mvc.MvcApplication.SimpleMembershipInitializer() in e:\Dev\DotNet\trunk\src\Coultard.App.Ui.Mvc\Global.asax.cs:391
   Coultard.App.Ui.Mvc.MvcApplication.Session_Start(Object sender, EventArgs e) in e:\Dev\DotNet\trunk\src\Coultard.App.Ui.Mvc\Global.asax.cs:297
   System.Web.SessionState.SessionStateModule.CompleteAcquireState() +409
   System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1269
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12319038
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

1 comment:

  1. It helped me! Thanks. Nice helpful exception as usual... MS really knows how to build easy to use frameworks!

    ReplyDelete