简体   繁体   中英

Error with Entity Framework and Postgresql

Error message:

[ Error message ]

I am using Entity Framework with Postgresql. When I want to list record from my database, the program gave this message. I have checked web.config, my connection string which is created by an entity framework is different from other projects' connection string.

web.config

[ web.config ]

<connectionStrings>
    <add name="projeEntities" 
         connectionString="metadata=res://*/Models.EntityFrameworks.ProjeModel.csdl|res://*/Models.EntityFrameworks.ProjeModel.ssdl|res://*/Models.EntityFrameworks.ProjeModel.msl;provider=Npgsql;provider connection string=&quot;Host=127.0.0.1;Database=proje;Username=postgres;Password=sdt2018;Persist Security Info=True&quot;" 
         providerName="System.Data.EntityClient" />
</connectionStrings>

I think this is wrong but, I did not any changing

如果使用的是https://www.npgsql.org/,则必须更改providerName =“ Npgsql”

Try to add this below code in your web.config file under system.data tag

<DbProviderFactories>
  <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
</DbProviderFactories>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM