简体   繁体   English

初始迁移后,EF6中的update-database命令不起作用

[英]update-database command in EF6 not working after initial migration

I got stuck at command: 我被命令卡住了:

update-database

while going through this tutorial by Tom Dysktra 阅读Tom Dysktra的教程时

Here is the error I am getting: 这是我得到的错误:

    PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Running Seed method.
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Invalid column name 'EmailAddress'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

... ...

    at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
An error occurred while executing the command definition. See the inner exception for details.

Did you try the verbose command? 您是否尝试了详细命令? I usually do the following in the console 我通常在控制台中执行以下操作

update-database -force -verbose

It also says no pending migrations. 它还说没有待定的迁移。 I am going to take shot in the dark and guess you have automatic migrations turned off. 我将在黑暗中拍摄照片,并猜测您已关闭自动迁移功能。 which means before you can update-database you need to create a migration 这意味着在您可以更新数据库之前,您需要创建一个迁移

add-migration NameItSomethingMeaningful

Now you can update-database 现在您可以更新数据库

这意味着在您的种子调用中,您发生了一些无效的SQL调用-特别是您有一个查询,该查询返回的值可能与您要强制转换的类型不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM