【发布时间】:2012-07-01 18:53:45
【问题描述】:
我们使用的是 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 - 或它认为会导致数据丢失的内容。
我不想在这里简单地启用“允许数据丢失”,而是想了解如何解决这些迁移问题。
提前谢谢你!
【问题讨论】:
标签: entity-framework ef-code-first code-first entity-framework-migrations