"执行code首先迁移"复选框从我的发布配置文件消失 [英] "Execute Code First Migrations" checkbox disappeared from my publish profile

查看:202
本文介绍了"执行code首先迁移"复选框从我的发布配置文件消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用网络部署来部署使用EF5 code第一的MVC4应用程序。我做了使用网络部署应用程序和数据库使用执行code首先迁移复选框上运行应用程序启动迁移被称为发展的发布配置文件。出版了一会儿伟大的工作。在某些时候,我增加了一个叫做测试部署到另一台服务器,它使用部署的ftp方法,也不会自动迁移一个新的发布配置文件。这工作也没关系。然而,当我试图用我的旧的发展再次发布的资料,VS自动改变设置的dbDacFx方式(更新数据库复选框,而不是执行code首先迁移),我不能让它回到方式,它是。
有在使用测试配置文件,该项目其他一些变化,但没有在我看来,像它可能导致此。有谁知道为什么VS认为我的项目不使用code第一了?

I'm using web deploy to deploy an MVC4 application using EF5 code first. I made a publish profile called "development" that uses web deploy for application and database using the 'Execute Code First Migrations' checkbox to run migrations on application startup. The publishing worked great for a while. At some point I added a new publish profile called "test" to deploy to another server, which uses the ftp method of deploy and no automatic migrations. This works fine too. However, when I tried to use my old "development" publish profile again, VS changes the settings automatically to the dbDacFx way ('Update database' checkbox instead of 'Execute Code First Migrations') and I can't get it back to the way it was. There were some other changes to the project while using the 'Test' profile, but nothing that seems to me like it could cause this. Does anyone know why VS thinks my project doesn't use code first anymore?

推荐答案

下面是正确的<一个href=\"http://stackoverflow.com/questions/16543229/publish-entity-framework-$c$c-first-migrations-with-no-context-in-the-startup-pr?answertab=active#tab-top\">answer - 解决了我的问题。
恰好是相反的重命名你的连接字符串作为您的DbContext,例如

Here is the right answer - is solved the problem for me. Just rename your connection string exactly as your DbContext, e.g.

        public ApplicationDbContext()
        : base("Vocabulary.Domain.ApplicationDbContext", throwIfV1Schema: false)
    {
    }

请注意该名称应该包括像Vocabulary.Domain.ApplicationDbContext命名空间。
不要忘了更新.pubxml文件:

Note that name should include namespace like "Vocabulary.Domain.ApplicationDbContext". Don't forget to update .pubxml files:

    <ObjectGroup Name="Vocabulary.Domain.ApplicationDbContext" Order="1" Enabled="True">

文章介绍时发布对话框中有或无蜱执行code首先迁移(在应用程序启动运行)

This article describes when publish dialog has or has no the tick "Execute Code First Migrations (runs on application start)"

这篇关于&QUOT;执行code首先迁移&QUOT;复选框从我的发布配置文件消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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