我们使用的是 EF 5RC,代码先迁移。我觉得这应该是一个容易回答的问题(我希望)。有没有一种好方法可以弄清楚自动迁移正在尝试做什么。
我通过 Add-Migration PS 命令添加了迁移。我已经调用了 Update-Database 并且该迁移似乎一切正常。现在 - 我只是像往常一样运行 Update-Database,但出现以下错误:
PM> update-database -Verbose
Using StartUp project 'Web'.
Using NuGet project 'DataAccess'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'UserGroup' (DataSource: (localdb)\v11.0, Provider: System.Data.SqlClient, Origin: Configuration).
No pending code-based migrations.
Applying automatic migration: 201206301526422_AutomaticMigration.
Automatic migration was not applied because it would result in data loss.
请注意,我正在添加 -Verbose 选项,并且我已经使用 -Script 再次尝试了它。但我不知道我们要迁移到什么地方;以及什么 SQL - 或它认为会导致数据丢失的内容。
我不想在这里简单地启用“允许数据丢失”,而是想了解如何对这些迁移进行故障排除。
先感谢您!