Rusty Divine
Rusty Divine

Reputation: 3492

Entity Framework 4.3.1 migrate.exe using /ConnectionString throws error

I have two projects that need to use EF 4.3.1 migrate.exe tool during a build script. It would be a pain to point to the transformed web.config, which is deployed on a server different than my build server, so I want to pass in the connection string as a flag.

I've tried every variation I can think of (different computers, SQL Server 2008, just a command line and not a .bat, running as an administrator, etc.), but I always get the error: ERROR: Exception has been thrown by the target of an invocation.

Here is an example of a .bat file I have tried on my local computer:

@rem run_db_migrations.cmd
SET StartUpDirectory=%CD%\MyProject.MVC\bin 
SET ConnectionString=Data Source=.\SQLEXPRESS;Initial Catalog=MyProject;Integrated Security=True
SET ConnectionStringProvider=System.Data.SqlClient
SET MigrateExe=.\packages\EntityFramework.4.3.1\tools\migrate.exe

%MigrateExe% MyProject.MVC.dll /StartUpDirectory:"%StartUpDirectory%" /ConnectionString:"%ConnectionString%" /connectionProviderName:%ConnectionStringProvider%
pause

I've seen other posts similar to this and they say this just works, but curiously their flags are slightly different, so I wonder if something has changed or if they mis-typed.

Upvotes: 2

Views: 1246

Answers (1)

angularsen
angularsen

Reputation: 8668

I answered a similar question here on how to override connectionstring through parameters to migrate.exe. However, I have yet to get it working without specifying a web/app.config file.

https://stackoverflow.com/a/14138797/134761

Upvotes: 1

Related Questions