Some problems in the Ef+postgresql

Source: Internet
Author: User
Tags postgresql connectionstrings

The MVC-based WEBAPI is needed to build a service interface, where data is stored in the PostgreSQL database and encountered many problems during use. Take a look at the record:

(1) System.IO.FileLoadException: Failed to load file or assembly "Npgsql, version=3.1.2.0, Culture=neutral, publickeytoken= 5d8b90d52f46fda7 "or one of its dependencies. The found assembly manifest definition does not match the assembly reference. (Exception from hresult:0x80131040)

The project is Codefirst, but it's always a mistake when it comes to building a project.

My steps are as follows

1, installation Entityframework6

Open the Package Manage Console and enter the command install-package entityframework;

2, installation of Npgsql entityframework support

Command Install-package Entityframework6.npgsql

3, Installation Npgsql

Command Install-package Npgsql

Sample configuration file Code

 <entityFramework> <defaultconnectionfactory type= " System.Data.Entity.Infrastructure.SqlConnectionFactory, entityframework "/> <providers> <provider Inva Riantname= "System.Data.SqlClient" type= "System.Data.Entity.SqlServer.SqlProviderServices, Entityframework.sqlserver "/> <provider invariantname=" Npgsql "type=" npgsql.npgsqlservices, Entityframework6.npgsql "/> </providers> </entityFramework> <system.data> <dbproviderfacto  ries> <remove invariant= "Npgsql" ></remove> <add name= "Npgsql Data Provider" invariant= "Npgsql" Description= ". Net Framework Data Provider for Postgresql Server" type= "npgsql.npgsqlfactory, Npgsql"/> </dbprov iderfactories> </system.data> <connectionStrings> <add name= "Testdbcontext" connectionstring= " Server=localhost;database=test; User Id=dba; password=12345678, "providername=" Npgsql "/> </connectionstrings> 

But don't know why, still will error!

Later, I was not the package installed in the wrong order!! Just change the top 2 and 3! Success!!!

Hey, it's drunk too! This little problem has been entangled for so long! Writing code needs to be more careful!

Some problems in the Ef+postgresql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.