Question

I am new to Postgres and I need help with connection string.

My app using Entity Framework. I have this connectionString to MSSQL Server:

<connectionStrings>
    <add name="DBContext" connectionString="Data Source=localhost;Initial Catalog=DB;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>

to my project i download a npgsql package (http://pgfoundry.org/projects/npgsql/) a need to help with editing connection string to Postgres database.

How to set providerName to npgsql?

Thank for help

Était-ce utile?

La solution

"don't hard code your providers" discusses this in detail.

It shows a setting like what you want:

<add name="blah" providerName="Npgsql" 
  connectionString="Server=127.0.0.1;Port=5432;Database=myDataBase;
    User Id=myUsername;Password=myPassword;"/>

but then explains why you should not do this, you should read the settings from your application's configuration file at runtime instead.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top