title: Entity Framework code first Object reference not set to an instance of an object
body: <p>I get the following error when I try to use EF code first, </p>
  
  <pre><code>Object reference not set to an instance of an object.
  </code></pre>
  
  <p>I get this when I try to run ANY query on a collection like e.g. <code>db.Surveys.ToList()</code>. I have also tried to run the Enable Migrations command, gives the same error.
  My web app is asp.net web forms and I am using EFv6.1.1 (latest).
  I have also added a connection string with the context name in my web.config.</p>
  
  <p>I have been using Entityframework for ages and never had this issue, any help is appreciated</p>
  
  <p><strong>Stacktrace</strong></p>
  
  <pre><code>System.NullReferenceException: Object reference not set to an instance of an object.
     at System.Web.UI.ParseChildrenAttribute.GetHashCode()
     at System.Collections.Generic.ObjectEqualityComparer`1.GetHashCode(T obj)
     at System.Collections.Generic.HashSet`1.InternalGetHashCode(T item)
     at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
     at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
     at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
     at System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider.GetAttributes(Type type)
     at System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider.&lt;&gt;c__DisplayClass4.&lt;GetAttributes&gt;b__3(PropertyInfo pi)
     at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
     at System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider.GetAttributes(PropertyInfo propertyInfo)
     at System.Data.Entity.ModelConfiguration.Conventions.PropertyAttributeConfigurationConvention`1.&lt;.ctor&gt;b__0(ConventionTypeConfiguration ec)
     at System.Data.Entity.ModelConfiguration.Conventions.TypeConvention.ApplyCore(Type memberInfo, ModelConfiguration modelConfiguration)
     at System.Data.Entity.ModelConfiguration.Conventions.TypeConventionBase.Apply(Type memberInfo, ModelConfiguration modelConfiguration)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyModelConfiguration(Type type, ModelConfiguration modelConfiguration)
     at System.Data.Entity.ModelConfiguration.Conventions.Convention.ApplyModelConfiguration(Type type, ModelConfiguration modelConfiguration)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyModelConfiguration(Type type, ModelConfiguration modelConfiguration)
     at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
     at System.Data.Entity.DbModelBuilder.&lt;&gt;c__DisplayClassd.&lt;MapTypes&gt;b__7(Type type)
     at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
     at System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
     at System.Data.Entity.DbModelBuilder.MapTypes(EdmModel model)
     at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
     at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
     at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
     at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
     at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
     at System.Data.Entity.Internal.LazyInternalContext.get_ModelBeingInitialized()
     at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
     at System.Data.Entity.Utilities.DbContextExtensions.&lt;&gt;c__DisplayClass1.&lt;GetModel&gt;b__0(XmlWriter w)
     at System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml)
     at System.Data.Entity.Utilities.DbContextExtensions.GetModel(DbContext context)
     at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
     at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
     at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
     at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()
     at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
     at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
     at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
     at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldInitialCreate(String language, String rootNamespace)
     at System.Data.Entity.Migrations.EnableMigrationsCommand.&lt;&gt;c__DisplayClass2.&lt;.ctor&gt;b__0()
     at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
  </code></pre>