title: FSharp data type provider for Postgresql
body: <p>I was trying FSharp data provider but against the Postgresql using npgsql. And I busted at very first line.</p>
  
  <p>When I am trying to create SqlDataConnection it is throwing error with message the connection string is not correct. </p>
  
  <blockquote>
    <p>The type provider
    'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders'
    reported an error: Keyword not supported: 'port:5432;database'.</p>
  </blockquote>
  
  <p>Now, I test connection string and also data using Servicestack.Ormlite. That basically uses IdbConnection. So, connection is all correct. But I don't know why Type Provider is not working.</p>
  
  <p>Here is code.</p>
  
  <pre><code>    //type dbSchema = SqlDataConnection&lt;ConnectionString = "Server=localhost;Port=5432; Database=TestDB;User Id=postgres;Password=g00gle*92;" &gt;
  [&lt;CLIMutable&gt;]
  type Person = 
      { ID : int;
        FirstName : string;
        LastName : string }
  
  [&lt;EntryPoint&gt;]
  let main args = 
      let dbFactory = 
          OrmLiteConnectionFactory
              (
               "Server=localhost;Port=5432; Database=TestDB;User Id=postgres;Password=*****;", 
               PostgreSqlDialect.Provider)
      use dbConnection = dbFactory.OpenDbConnection()
      Console.WriteLine dbConnection.State
      let persons = dbConnection.Select&lt;Person&gt;()
      persons.ForEach(fun p -&gt; Console.WriteLine p.FirstName)
      Console.Read() |&gt; ignore
      0
  </code></pre>
  
  <p>In above code first commented line is not working while with same settings below code is working. That means issue is only with type provider not with connections IMHO.</p>
  
  <p>Do I need to do any other settings. </p>
  
  <p>Please let me know if any other details are required.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After kvb's comment I tried both. Here is updated code with web config.</p>
  
  <pre><code>//type dbSchema = SqlEntityConnection&lt;ConnectionStringName = "TestDB", Provider="Npgsql"&gt;
      type dbSchema = SqlEntityConnection&lt; ConnectionStringName="TestDB" &gt;
  
      [&lt;CLIMutable&gt;]
      type Person = 
          { ID : int;
            FirstName : string;
            LastName : string }
  
      [&lt;EntryPoint&gt;]
      let main args = 
          let dbFactory = 
              OrmLiteConnectionFactory
                  (
                   "Server=localhost;Port=5432; Database=TestDB;User Id=postgres;Password=*******;", 
                   PostgreSqlDialect.Provider)
          use dbConnection = dbFactory.OpenDbConnection()
          Console.WriteLine dbConnection.State
          let persons = dbConnection.Select&lt;Person&gt;()
          persons.ForEach(fun p -&gt; Console.WriteLine p.FirstName)
          Console.Read() |&gt; ignore
          0
  </code></pre>
  
  <p>And here is web config</p>
  
  <pre><code>  &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;add name="Npgsql Data Provider"
              invariant="Npgsql"
              description="Data Provider for PostgreSQL"
              type="Npgsql.NpgsqlFactory, Npgsql" /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
    &lt;connectionStrings&gt;
      &lt;add name="TestDB"
            connectionString="Server=localhost:5432; Database=TestDB;User Id=postgres;Password=******;"
            providerName="Npgsql" /&gt;
  
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>and here is assembly in appconfig. I don't think it will be in GAC as I added via nuget</p>
  
  <pre><code> &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" /&gt;
      &lt;bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0" /&gt;
   &lt;/dependentAssembly&gt;
  </code></pre>
  
  <p>Above both one is commented and another one without which is not commented both is failing with different error.
  First one is failing with error</p>
  
  <blockquote>
    <p>The type provider
    'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders'
    reported an error: Error reading schema. error 7001: The specified
    store provider 'Npgsql' cannot be found in the configuration, or
    'Npgsql' is not valid. Unable to find the requested .Net Framework
    Data Provider.  It may not be installed.</p>
  </blockquote>
  
  <p>and second one is with this error</p>
  
  <blockquote>
    <p>The type provider
    'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders'
    reported an error: Error reading schema. error 7001: The provider did
    not return a ProviderManifestToken string. A network-related or
    instance-specific error occurred while establishing a connection to
    SQL Server. The server was not found or was not accessible. Verify
    that the instance name is correct and that SQL Server is configured to
    allow remote connections. (provider: Named Pipes Provider, error: 40 -
    Could not open a connection to SQL Server) The network path was not
    found</p>
  </blockquote>
  
  <p>I still not understand why it is searching for SQL server.</p>
  
  <p>Please let me know if any further infromation required.</p>