I want to execute (code-first) migrations using a connectionString that I have constructed myself.

The entry point is a static function with one parameter, the connectionString.

I have a DbContext class called PocModel with both a default constructor. 

```
public PocModel() : base("PocModel")
{ ...

```

And a context constructor with a string argument:

```
public PocModel(string nameOrConnectionString): base(nameOrConnectionString)
{ ...

```

My goal is to perform migrations on the database that is targeted by the connectionString, not the connectionString that EF "magically" creates via the name only (localhost\sqlexpress - PocModel).

This I have not been able to do.

I have an "outer" function declared like this:

```
public static void MigrateDatabase(string connectionString)
{ ...

```

This function I have tried to implement in the flw. ways:

```
 DbMigrator migrator = new DbMigrator(new Migrations.Configuration());
 migrator.Configuration.TargetDatabase = new  DbConnectionInfo(connectionString, "System.Data.SqlClient");
 migrator.Update();

```

And like this:

```
Database.DefaultConnectionFactory = new SqlConnectionFactory(connectionString);
 Database.SetInitializer<PocModel>(new MigrationInitializer());
 PocModel model = new PocModel(connectionString);
 model.Dispose();

```

I have even tried to dynamically set the 

```
ConfigurationManager.ConnectionString["PocModel"]

```

To the connectionString passed in.

But alas, all fails and the default PocModel constructor is invoked from within the EF migration code, targetting server:localhost\sqlexpress and database:PocModel.

I have not been able to perform migrations to any database not named "PocModel" residing on "localhost\sqlexpress".

It is not an option for me to be using an app.config file to set my connectionString, as I need to pass this in via the static outer function.

Please help, been stuck on this problem for a very long time now.

EDIT:
I have made it work by this hack, but I am asking the question in order to verify that there indeed is no other solution to the problem (aka the EF migrations is faulty)

```
  private static string _databaseNameOrConnectionString = "PocModel";

        internal static string DatabaseNameOrConnectionString
        {
            get { return _databaseNameOrConnectionString; }
            //HACK: This setter must ONLY be called from SetupModule.MigrateDatabase. It is a hack to circumvent the code-first migrations usage of this ctor.
            set { _databaseNameOrConnectionString = value; }
        }

        //the code first migrations will call this ctor and ignore the connectionString it have been passed.
        public PocModel()
            : base(DatabaseNameOrConnectionString)
        {

```