【发布时间】:2016-09-28 08:56:16
【问题描述】:
我们的项目使用 Entity Framework 6.0 和 .NET 4.5,FAT-Client 和 Code-First 方法。
我们有大约 20 个迁移文件(C# 部分类)通过 Visual Studio 包管理器控制台中的 cmdlet Add-Migration 自动生成,并通过 Update-Database 成功应用。
现在,我们的客户有一个集成数据库,已经应用了大约 10 个迁移,我们现在需要应用剩余的 10 个迁移。我们使用Update-Database -Script -SourceMigration:<migration10> 为剩余的迁移生成SQL 脚本。在这种情况下——以及在使用SourceMigration:$InitialDatabase 时——会显示以下错误:
[...]
Applying explicit migration: 201609141617112_HostAufbauIdentifier.
Applying explicit migration: 201609141622583_RemPerStaWe.
System.Xml.XmlException: 'SoftwareAuftrag_Auftrag' is an unexpected token. Expecting white space. Line 1943, position 92.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ThrowExpectingWhitespace(Int32 pos)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Data.Entity.Migrations.Edm.ModelCompressor.Decompress(Byte[] bytes)
at System.Data.Entity.Migrations.DbMigration.GetModel(Func`2 modelAccessor)
at System.Data.Entity.Migrations.DbMigration.GetTargetModel()
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.ScriptUpdate(String sourceMigration, String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdateRunner.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.ScriptUpdate(String sourceMigration, String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
在引起问题的文件中,这里是201609141622583_RemPerStaWe,绝对不会对名称为SoftwareAuftrag 或类似名称的任何内容进行任何处理。这些东西是在以前的迁移中完成的,在那里,我也完全没有看到任何问题。
我尝试通过代码附加调试器,但我不知道在哪里设置断点。在这种情况下,“发生异常时中断”的选项似乎不会触发中断。也许另一个子进程是从包管理器启动的。
我不知道如何解决这个问题,我们为此浪费了大量时间。希望有人对此有所暗示。 ;)
更新
我系统地删除了单个迁移文件,直到我发现恰好 3 个组合在一起导致错误。但是,当我取消注释 up 和 down 中的所有内容时,错误仍然存在。删除全部 3 个迁移文件时,错误消失了。这有什么意义?资源文件有问题?我不知道...
【问题讨论】:
标签: c# entity-framework ef-code-first entity-framework-migrations