After a while of searching we installed
EntityFramework6.Npgsql 6.4.1 package in all solution's projects (There are some class liberaries and WinApps projects in the solution). With the update of this package,
Npgsql update to the new version
(4.1.3) too. So the app.config change to :
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
<defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, EntityFramework6.Npgsql" />
</entityFramework>
It needs to be changed app.config as below. Just in the project that DataContext has located (DataLayer)
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
Replace with :
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
at the end, we have to set DataLayer (With DataContext) as StartUp Project. (
Set as StartUp Project) and then we can migrate code first project with
PostgreSql database by using
add-migration and
update-database commands in
PackageManagerConsole.