数据库中已经有一个名为"__MigrationHistory"的对象 [英] There is already an object named '__MigrationHistory' in the database

查看:476
本文介绍了数据库中已经有一个名为"__MigrationHistory"的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在远程数据库上执行 SQLQuery (由Visual Studio中的Update-Database -Verbose -f -Script本地生成)时,我看到SQL Server Management Studio返回以下错误:

When I tried to execute SQLQuery (generated by Update-Database -Verbose -f -Script locally in Visual Studio) on remote database, I see the following error returned by SQL Server Management Studio:

消息2714,第16级,状态6,第1行

Msg 2714, Level 16, State 6, Line 1

数据库中已经有一个名为"__MigrationHistory"的对象.

There is already an object named '__MigrationHistory' in the database.

如何解决这个问题?

推荐答案

__MigrationHistory是EF使用的自动生成的表,用于跟踪对其数据库应用了哪些升级/补丁. EF完全了解该表并自行处理.您应该创建/删除/更改该表.看来您的数据库已经有该表.如果EF或您的升级脚本试图创建这样的表,这很奇怪.您需要仔细检查所有内容并猜测/了解实际发生的情况,因为EF崩溃了,或者您的脚本准备得不正确.

__MigrationHistory is an auto-generated table used by EF to track what upgrades/patches it has applied to the database. EF is completely aware of that table and handles it on its own. You should ot create/drop/alter that table. It seems your database already has that table. If EF or your upgrade-script tries to create such table, this is strange. You need to carefully review everything and guess/learn what really has happened, because either EF went wild, or your scripts are prepared in a wrong way.

这篇关于数据库中已经有一个名为"__MigrationHistory"的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆