I have an existing ASP.NET app which is configured to connect to a MS SQL Server database and I am trying to modify it to use a postgres database instead.
I would like to avoid modifying the C# code, if possible.
I expected that the following changes would be sufficient:
- Add a reference to a suitable postgres driver, in this case
NauckIT.PostgreSQLProvider.dll
- Add a
provider
tag to specify the driver to use, in this case:
<connectionStrings> <add name="default" connectionString="Server=127.0.0.1;Port=5432;User Id=finnw;Password=XXX;Database=default;Pooling=false" providerName="Npgsql" /> </connectionStrings>
But the providerName
tag seems to have no effect (although it does not in itself generate an error.) Instead I still see this error message in the browser:
[ArgumentException: Keyword not supported: 'port'.]
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +4907604
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +55
It looks as though it is still trying to use the MS SQL Server driver.
How do I persuade it not to?
I am using ASP.NET Development Server, not IIS. Initially I thought this might be the problem but this forum post suggests otherwise.