问题
I am working on a project using EntityFramework 6.1.1 and npgsql 2.2.3 within Visual Studio 2012 Update 4. To do so I installed npgsl using the supplied setup and installed the nuget packages "Npgsql" and "Npgsql for Entity Framework" (and "EntityFramework" itself, of course).
Every thing used to be fine: I could successfully access my database for a while - until at some day everything "blew up".
This is the event history:
- Fixing compiler errors after a major code upgrade I encountered these error messages:
- "could not load npgsl.EntityFrameworkLegacy assmbly" (I did neither install nor reference this assembly)
- A whole bunch of "Metadata file 'xxx' could not be found" errors where 'xxx' referred to all my own project assemblies
- I've found possible solutions the "Metadata file" problems - like deleting the .suo file, checking the project build order and so on. None of them fixed the problem. So I deleted the .edmx file (and thus all automatically generated database access files) from my project. This fixed the "Metadata file" problems - introducing "unresolved symbols" of course.
- I tried to add a new "ADO.NET Entity Data Model" to my project to regain database access. Only all PostgreSQL database connections where not listed any more in the connection list. Also I could not create new PostgreSQL connections because this data source was not listed. Though this did not affect the global "data connections" dialog within Visual Studio: here I could still access my PostgreSQL connections.
- I reinstalled npgsql using the setup. Now I could create a new "ADO.NET Entity Data Model" and connect to my PostgreSQL database. But this time I'm getting the error message: "Your project references the latest version of Entity Framework; however, and Entity Framework database provider compatible with this version could not be found [...]". This is where I am stuck now.
My current setup is:
- the project refers to the following assemblies:
- EntityFramework 6.1.1 for .NET 4.5
- EntityFramework.SqlServer 6.1.1 for .NET 4.5
- Npgsql 2.2.3 for .NET 4.5
- Npgsql.EntityFramework 2.2.3 for .NET 4.5
- This is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
</configuration>
- I have this in my machine.config (both 32bit and 64bit):
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
</DbProviderFactories>
</system.data>
Of dourse I tried to rebuild my solution before adding the new model. But this didn't help.
Are there any other configuration issues I may have missed?
Anybody who could explain me my why all this happened at all?
来源:https://stackoverflow.com/questions/27566523/entity-framework-6-1-1-and-npgsql-2-2-3-compatible-entity-framework-database-pr