Entity Framework Code-First: Generate SQL script with 'Update-Database' produces XML error while parsing
<p>Our project uses Entity Framework 6.0 with .NET 4.5, FAT-Client with Code-First approach.</p>

<p>We have about 20 migration-files (C# partial classes) generated automatically via the cmdlet <code>Add-Migration</code> in the Visual Studio Package Manager Console, and applied successfully via <code>Update-Database</code>.</p>

<p>Now, our client has an integration database that has around 10 migrations applied already, and we need to apply the remaining 10 migrations now. We used <code>Update-Database -Script -SourceMigration:&lt;migration10&gt;</code> in order to produce a SQL script for the remaining migrations. In this case – and also when using <code>SourceMigration:$InitialDatabase</code> – the following error is displayed:</p>

<pre><code>[...]
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.&lt;&gt;c__DisplayClass2.&lt;.ctor&gt;b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
</code></pre>

<p>In the file that causes trouble, here <code>201609141622583_RemPerStaWe</code>, absolutely nothing is done with anything that has a name of <code>SoftwareAuftrag</code> or alike. This stuff is done in previous migrations, and there, I also don't see any problem at all.</p>

<p>I tried attaching the debugger via code, but I don't know where to set a break point. The option to 'break when an exception occurs' doesn't seem to trigger a break in this case. Maybe another sub-process is started from the package manager.</p>

<p>I have no clue how I could break down the problem, and we lose a ton of time on this. Hopefully someone has a hint on this. ;)</p>

<h2>UPDATE</h2>

<p>I systematically deleted individual migration files until I found exactly 3 that in combination cause the error. But when I uncomment everything in <code>up</code> and <code>down</code> the error persists. When deleting the whole 3 migration files, the error is gone. How does that make sense? Problems with resource files? I don't know...</p>