PostgreSQL syntax highlighting in Visual Studio 2017

Viewed 1214

When I create a .sql file in Visual Studio 2017 the syntax highlighting assumes I am using MSSQL and highlights valid PostgreSQL queries as having errors.

Is there any way to get Visual Studio 2017 to have proper syntax highlighting in .sql files for PostgreSQL?

2 Answers

If you are using a PostgreSQL plug-in, you need to rename your file to either ‘psql’ or ‘pgsql’ to enable to correct syntax highlighting.

You should use npgsql so you will not have these types of conflicts in the entity framework, plus you can check my repository on github.

and dont forget to define the dataprovider on the web.config:

<system.data>
    <DbProviderFactories>
      <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql" type="Npgsql.NpgsqlFactory, Npgsql" />
    </DbProviderFactories>
</system.data>

<entityFramework>
    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
    <defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
</entityFramework>
Related