Entity Framework Migrations Error - Sequence contains no elements

.net ado.net-entity-data-model edmx ef-code-first entity-framework

Question

verbose "command: add-migration"
error: Sequence is devoid of elements.

Before seeing this problem, I took a few actions. I modified my code-first model, but I didn't execute it.add-migration yet. Then, in order to experiment visually, I created an EDMX model. I eliminated the EDMX model after seeing it was interfering with my code. I attempted to flee.add-migration and the response was "Sequence includes no elements." With the exception of my customizations, I updated to EF 5 and deleted the previous Migrations package. I then tried.add-migration and I continue to get the message "Sequence includes no components." The remainder of the mistake is below.

System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.GetQualifiedTableName(XDocument model, String entitySetName)
   at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<FindRenamedIndependentAssociationColumns>b__ba(<>f__AnonymousType16`2 <>h__TransparentIdentifieraa)
   at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()
   at System.Linq.Enumerable.<DistinctIterator>d__81`1.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(XDocument sourceModel, XDocument targetModel, String connectionString)
   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.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
Sequence contains no elements
1
28
9/19/2012 6:23:12 PM

Accepted Answer

It seems to be a bug. Would you mind submitting it at http://entityframework.codeplex.com/workitem/list/advanced with information enabling the issue to be reproduced?

2
9/20/2012 5:14:58 AM

Popular Answer

I encounter this issue while attempting to describe the type and size of a column usingDataAnnotations .

BAD:

[Column(TypeName="VARCHAR(254)")]
public string ColumnName { get; set; }

OK:

[MaxLength(254)]
[Column(TypeName="VARCHAR")]
public string ColumnName { get; set; }


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow