title: EF 6.1 Sequence Contains more then one element
body: <p>I Updated my EF from 5 to 6 today , I followed following steps from MSDN: </p>
  
  <p><a href="http://msdn.microsoft.com/en-us/data/upgradeef6.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/data/upgradeef6.aspx</a></p>
  
  <p>The problem now is, when I query against any repository, such as like this:</p>
  
  <pre><code>mapEntitiesContext.ContextParameterScreens
                    .Where(p =&gt; p.OwningTenantId == IdentityHelper.IdPrv.TenantId)
                    .Select(p =&gt; new
                                 {
                                     p.ParameterScreenDefinitionId,
                                     p.MedicalContextId
                                 })
                    .FirstOrDefault();
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Sequence contains more then one element.</p>
  </blockquote>
  
  <p>I never had this issue with EF 5.0.</p>
  
  <pre><code>Stacktrace
  
      System.InvalidOperationException: Sequence contains more than one element
  
  Result StackTrace:  
  
     at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.&lt;&gt;c__DisplayClass281.&lt;IndexesEqual&gt;b__27e(String c)
     at System.Linq.Enumerable.&lt;&gt;c__DisplayClass12`3.&lt;CombineSelectors&gt;b__11(TSource x)
     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
     at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.IndexesEqual(ConsolidatedIndex consolidatedIndex1, ConsolidatedIndex consolidatedIndex2, ICollection`1 renamedColumns)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.&lt;&gt;c__DisplayClass272.&lt;FindAddedIndexes&gt;b__26e(ConsolidatedIndex i1, ConsolidatedIndex i2)
     at System.Data.Entity.Utilities.DynamicEqualityComparer`1.Equals(T x, T y)
     at System.Linq.Set`1.Find(TElement value, Boolean add)
     at System.Linq.Set`1.Add(TElement value)
     at System.Linq.Enumerable.&lt;ExceptIterator&gt;d__99`1.MoveNext()
     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
     at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
     at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source, ModelMetadata target, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion)
     at System.Data.Entity.Internal.InternalContext.ModelMatches(VersionedModel model)
     at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata, DatabaseExistenceState existenceState)
     at System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata, DatabaseExistenceState existenceState)
     at System.Data.Entity.Database.CompatibleWithModel(Boolean throwIfNoMetadata, DatabaseExistenceState existenceState)
     at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
     at System.Data.Entity.Internal.InternalContext.&lt;&gt;c__DisplayClassf`1.&lt;CreateInitializationAction&gt;b__e()
     at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
     at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
     at System.Data.Entity.Internal.LazyInternalContext.&lt;InitializeDatabase&gt;b__4(InternalContext c)
     at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
     at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
     at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
     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](IQueryable`1 source, Expression`1 predicate)
  </code></pre>