title: Glimpse EF6: first chance exception of type 'System.NullReferenceException' occurred in EntityFramework.SqlServer.dll
body: <p>The following code is throwing the first chance exception:</p>
  
  <pre><code>public HttpResponseMessage Get(int id)
  {
          try
          {
              var module = _module.ODataQueryable().SingleOrDefault(m =&gt; m.ModuleId == id);
              return Request.CreateResponse(HttpStatusCode.Created, module);
          }
          catch (Exception ex)
          {
              Log.ErrorException("Error adding module", ex);
              return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
          }
  }
  </code></pre>
  
  <p>If we replace the <code>id</code> variable with a hard coded int value eg 34 then the code runs.  </p>
  
  <p>The source of the exception is <code>Glimpse.EF6</code> and the stacktrace is:</p>
  
  <pre><code>   at Glimpse.EF.AlternateType.GlimpseDbProviderServices.SetDbParameterValue(DbParameter parameter, TypeUsage parameterType, Object value)
     at System.Data.Entity.Core.Common.DbProviderServices.SetParameterValue(DbParameter parameter, TypeUsage parameterType, Object value)
     at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.SyncParameterProperties(EntityParameter entityParameter, DbParameter storeParameter, DbProviderServices storeProviderServices)
     at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.PrepareEntityCommandBeforeExecution(EntityCommand entityCommand)
     at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
     at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClass7.&lt;GetResults&gt;b__6()
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClass7.&lt;GetResults&gt;b__5()
     at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator&gt;b__0()
     at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
     at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
     at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.&lt;GetElementFunction&gt;b__2[TResult](IEnumerable`1 sequence)
     at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
     at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
     at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
     at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
     at Denarii.Issuing.Web.ClientPortal.Api.ModuleController.Get(Int32 id) in c:\Projects\Denarii.Issuing\Denarii.Issuing.Web.ClientPortal\Api\ModuleController.cs:line 64
  </code></pre>
  
  <p>Do I need to debug the Glimpse EF6 plugin? The module service (_module) works when called from a WinForms app or a console app. Any help much appreciated.</p>