什么是没有一个Web / App.config的运行实体框架migrate.exe工具的正确格式? [英] What is the correct format for Running Entity Framework migrate.exe tool without a Web/App.config?

查看:157
本文介绍了什么是没有一个Web / App.config的运行实体框架migrate.exe工具的正确格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我们切换到实体框架数据迁移和我工作的一些构建自动化脚本,我们的MVC应用程序。我可以用migrate.exe工具4.3成功运行从我们构建服务器的迁移的如果我有一个Web.config以点吧的命令如下所示:

We recently switched to Entity Framework data migrations and I am working on some build automation scripts for our MVC app. I can successfully run the migrations from our build server using the migrate.exe tool in 4.3 if I have a Web.config to point it at. The command looks something like:

ProjectName\packages\EntityFramework.4.3.1\tools\migrate.exe MyAssembly
    /startupdirectory:ProjectName\bin\Debug 
    /startupconfigurationfile:ProjectName\Web.config 
    /verbose

然而,由于种种原因,我想避免使用Web.config文件,只是传递正确的连接字符串中的迁移时间:

However, for various reasons I would like to avoid using the Web.config and just pass in the correct connection string at the time of the migration:

ProjectName\packages\EntityFramework.4.3.1\tools\migrate.exe MyAssembly
    /startupdirectory:ProjectName\bin\Debug 
    /connectionString:"Data Source=awesomeserver;Initial Catalog=awesomedatabase;User Id=funkyuser;Password=crazypassword" 
    /verbose

这是行不通的。更糟的是,它崩溃migrate.exe与一个NullReferenceException。连接字符串是相同的,我们在我们的Web.config中使用的一个。

This does not work. Worse, it crashes migrate.exe with a NullReferenceException. The connection string is identical to the one we use in our Web.config.

任何人都遇到过吗?是我的连接字符串格式错误?错误?

Anyone encountered this before? Is my connection string format wrong? Bug?

推荐答案

好吧,我们理解了它。当没有在Web.config运行,则connectionProviderName参数也必须在通过

Ok, we figured it out. When running without the Web.config, the connectionProviderName parameter must also be passed in:

ProjectName\packages\EntityFramework.4.3.1\tools\migrate.exe MyAssembly
    /startupdirectory:ProjectName\bin\Debug 
    /connectionProviderName:"System.Data.SqlClient"
    /connectionString:"Data Source=awesomeserver;Initial Catalog=awesomedatabase;User Id=funkyuser;Password=crazypassword" 
    /verbose

我已经证实了这个工程。

I have confirmed that this works.

这篇关于什么是没有一个Web / App.config的运行实体框架migrate.exe工具的正确格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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