实体框架迁移错误-序列不包含任何元素 [英] Entity Framework Migrations Error - Sequence contains no elements

查看:102
本文介绍了实体框架迁移错误-序列不包含任何元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命令: add-migration blahblah -verbose

错误:序列不包含任何元素

command: add-migration blahblah -verbose
error: Sequence contains no elements

在收到此错误之前,我做了几件事。我对代码优先模型进行了更改,但尚未运行 add-migration 。然后,我添加了一个EDMX模型,以便在视觉上尝试一个想法。我意识到EDMX模型弄乱了我的代码,所以我删除了它。我试图运行 add-migration 并得到序列不包含任何元素。除配置外,我升级到EF 5并卸载了旧的Migrations软件包。然后,我再次尝试 add-migration ,仍然出现序列不包含任何元素。下面是其余的错误。

I did a few things before getting this error. I made a change to my code-first model but did not runadd-migration yet. Then I added an EDMX model to play around with an idea visually. I realized the EDMX model was messing with my code so I removed it. I tried to run add-migration and got "Sequence contains no elements". I upgraded to EF 5 and uninstalled the old Migrations package except for my configurations. Then I tried add-migration again and I am still getting "Sequence contains no elements". Below is the rest of the error.

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


推荐答案

看起来像个错误。您介意将其归档在 http://entityframework.codeplex.com/workitem/list/advanced详细信息可以重现问题吗?

Looks like a bug. Do you mind filing it at http://entityframework.codeplex.com/workitem/list/advanced with details allowing to reproduce the problem?

这篇关于实体框架迁移错误-序列不包含任何元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆