title: sequence contains more than one element code first add-migration
body: <p>The below is the entity, when I am going to add-migration, it is giving me exception. </p>
  
  <pre><code>public class MyEntity
      [Key]
      public int ID { get; set; }
  public string Name { get; set; }
  
  
  [NotMapped]
  public HttpPostedFileBase DiagramFMCDocumentUpload { get; set; }
  //[ForeignKey("DiagramFMCDocumentID")]
  //public Document DiagramFMCDocument { get; set; }
  //public int? DiagramFMCDocumentID { get; set; }
  
  //[NotMapped]
  //public HttpPostedFileBase ExecutedDeedDocumentUpload { get; set; }
  
  public Document ExecutedDeedDocument { get; set; }
  
  [ForeignKey("ExecutedDeedDocument")]
  [InverseProperty("ExecutedDeedDocument")]
  public int? ExecutedDeedDocumentID { get; set; }
  
  [NotMapped]
  public HttpPostedFileBase DCertificationDocumentUpload { get; set; }
  
  public Document DCertificationDocument { get; set; }
  
  [ForeignKey("DCertificationDocument")]
  [InverseProperty("DCertificationDocument")]
  public int? DCertificationDocumentID { get; set; }
  
  ////ForeignFundBasicType
  //public int ForeignFundStructureTypeFDID { get; set; }
  </code></pre>
  
  <p>}</p>
  
  <p>When I am commenting out some Document &amp; FOreignKey fields, it perfects fine but more than one foreign key it is not working fine. Here's the exception.</p>
  
  <pre><code>System.InvalidOperationException: Sequence contains more than one element
     at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.&lt;&gt;c__DisplayClass293.&lt;&gt;c__DisplayClass295.&lt;FindRenamedIndexes&gt;b__28b(String c)
     at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
     at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.&lt;&gt;c__DisplayClass293.&lt;FindRenamedIndexes&gt;b__28a(&lt;&gt;f__AnonymousType30`2 &lt;&gt;h__TransparentIdentifier286)
     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.Migrations.DbMigrator.Scaffold(String migrationName, String namespace, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(String migrationName, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder scaffolder)
     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.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.AddMigrationCommand.&lt;&gt;c__DisplayClass2.&lt;.ctor&gt;b__0()
     at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
  Sequence contains more than one element
  PM&gt; Add-Migration First -Force
  System.InvalidOperationException: Sequence contains more than one element
     at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.&lt;&gt;c__DisplayClass293.&lt;&gt;c__DisplayClass295.&lt;FindRenamedIndexes&gt;b__28b(String c)
     at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
     at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer)
     at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.&lt;&gt;c__DisplayClass293.&lt;FindRenamedIndexes&gt;b__28a(&lt;&gt;f__AnonymousType30`2 &lt;&gt;h__TransparentIdentifier286)
     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.Migrations.DbMigrator.Scaffold(String migrationName, String namespace, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(String migrationName, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder scaffolder)
     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.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
     at System.Data.Entity.Migrations.AddMigrationCommand.&lt;&gt;c__DisplayClass2.&lt;.ctor&gt;b__0()
     at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
  </code></pre>