c# – 实体框架代码优先:使用’Update-Database’生成SQL脚本在
我们的项目使用Entity Framework 6.0和.NET 4.5,FAT-Client和Code-First方法.
我们在Visual Studio包管理器控制台中通过cmdlet Add-Migration自动生成了大约20个迁移文件(C#部分类),并通过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 lastMigrationId) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Upgrade(IEnumerable`1 pendingMigrations,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或类似的东西.这些东西在以前的迁移中完成,在那里,我也没有看到任何问题. 我尝试通过代码附加调试器,但我不知道在哪里设置断点.在发生异常时“中断”的选项似乎不会在这种情况下触发中断.也许从包管理器启动另一个子流程. 我不知道如何解决这个问题,我们在这方面会失去很多时间.希望有人对此有所暗示. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |