[英]An exception of type 'System.Xml.XmlException' occurred in EntityFramework.dll but was not handled in user code
New to programming, new to stackoverflow, so apologies if this is not an appropriate question. 编程新手,对stackoverflow不熟悉,如果这不是一个合适的问题,请道歉。 I am getting a error message and I am completely dumbfounded as too what is wrong with my program.
我收到一条错误消息,我完全傻眼了,因为我的程序出了什么问题。
Basically, whenever I try to call a view, I get the error as described in the title. 基本上,每当我尝试调用视图时,我都会收到标题中描述的错误。 Some examples of where my program is failing:
我的程序失败的一些例子:
Line 22: public ActionResult Index()
Line 23: {
**Line 24: return View(db.hostSystems.ToList());**
Line 25: }
Line 26:
Below is a different example: 以下是一个不同的例子:
Line 20: public ActionResult Index()
Line 21: {
**Line 22: var hostDocuments = db.hostDocuments.Include(b => b.hostSystem);**
Line 23: return View(hostDocuments.ToList());
Line 24: }
This is happening on every single view. 每个视图都会发生这种情况。 I have tried to scaffold a new instructor, but again, but the error occurs on any generated views.
我已经尝试过搭建一个新的教师,但是再一次,但是在任何生成的视图上都会出现错误。
I also get the same error when I try to run an update-database on the Package Management console: 当我尝试在Package Management控制台上运行update-database时,我也遇到了同样的错误:
PM> update-database -Force
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201610121010400_InitialCreate, 201610141128247_NewFields, 201610141215392_changes, 201610141223280_changes2].
Applying explicit migration: 201610121010400_InitialCreate.
System.Xml.XmlException: Syntax for an XML declaration is invalid. Line 1, position 21.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl)
at System.Xml.XmlTextReaderImpl.Read()
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.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.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.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.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Syntax for an XML declaration is invalid. Line 1, position 21.
Everything was working fine yesterday. 昨天一切都很好。 I came in today and started to use my machine and have had this problem ever since.
我今天进来并开始使用我的机器,从那时起就遇到了这个问题。 I am absolutely besides myself on what is wrong, and just can't understand why this is now occurring.
我绝对不知道自己出了什么问题,只是不明白为什么现在这样。 Have checked many other threads that haven't helped.
检查了许多其他没有帮助的线程。
Thank you for any assistance. 谢谢你的帮助。
In the end it was due to a corrupted migration. 最终,这是由于迁移的破坏。 I am still investigating the problem, but it is solved.
我仍在调查这个问题,但它已经解决了。
Thanks all 谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.