Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework - Update-database Command Prompting for ConnectionProviderName

I am trying to run Update-Database with a provided connection string. For my tests, I added the -Script flag such to be non-destructive

It appears as though parameter ConnectionProviderName is required in the connection string but simply adding it causes this error:

Keyword not supported: 'ConnectionProviderName'

I am having trouble passing in the parameter "ConnectionProviderName"

I can run the command in 2 steps as seen below but I would rather do the command in 1 step.

   PM> update-database -ConnectionString 'data source=10.10.10.20;initial  catalog=MyDatabase;user id=db_user;password=1234;'  -Script

Returns the following request for more info, which I then need to provide:

cmdlet Update-Database at command pipeline position 1
Supply values for the following parameters:
ConnectionProviderName: System.Data.SqlClient

After I provide the ConnectionProviderName, the command runs fine.

How can I do this in 1 command?

Thanks

like image 288
Slinky Avatar asked Mar 23 '15 16:03

Slinky


2 Answers

The param ConnectionProviderName cannot be specified in the connection string; it must be it's own param, apparently, because the following works

update-database -ConnectionString 'data source=10.10.10.20;initial  catalog=MyDatabase;user id=db_user;password=1234;'  -ConnectionProviderName System.Data.SqlClient  -Script
like image 162
Slinky Avatar answered Oct 28 '22 16:10

Slinky


Yes, they are separate arguments. When you put these in a configuration file (which I would recommend), you use

<add name="myConnection"
    connectionString="data source=10.10.10.20;initial  catalog=MyDatabase;user id=db_user;password=1234;"
    providerName="System.Data.SqlClient" />

If you only have one connection string in your config file then you can simply call update-database. If you have multiple however, you have to call it with update-database -ConnectionStringName "myConnection" to distinguish between each connection.

If you really want to specify it in every call then you just specify both arguments.

like image 32
Jeroen Vannevel Avatar answered Oct 28 '22 18:10

Jeroen Vannevel