Configuring Entity Framework 6.0
The PSQL ADO.NET Entity Framework data provider supports the Microsoft ADO.NET Entity Framework versions 5.0 (EF5) and 6.0 (EF6).
To use EF6, you must first register it using one of the following methods:
NOTE: To register EF6 while testing your applications locally, you can perform a code-based registration during development. However, when you deploy your project, you must perform a configuration file registration.
Configuration File Registration
1
Install the EntityFramework 6 NuGet package.
An app.config file is created.
2
Remove the defaultConnectionFactory registration section from the app.config file and replace it with the following code:
<providers>
<provider invariantName="Pervasive.Data.SqlClient"
type="Pervasive.Data.SqlClient.Entity.PsqlProviderServices, Pervasive.Data.SqlClient.Entity, Version=4.2.0.6, Culture=neutral, PublicKeyToken=c84cd5c63851e072" />
</providers>
The EF6 provider registration is added to Entity Framework section of the app.config file.
Code-Based Registration
1
Add the following new DbConfiguration class to your test application:
public class MyConfiguration : DbConfiguration
{
public MyConfiguration()
{
SetProviderServices("PsqlProviderServices.ProviderInvariantName, new PsqlProviderServices());
}
}
2
[DbConfigurationType(typeof(MyConfiguration))]
Using Multiple Entity Framework Versions Against the Same Database
A single database can use multiple versions of the Microsoft ADO.NET Entity Framework: 5.0 (EF5) and 6.0 (EF6). However, when you switch between EF5 and EF6 applications against the same database, you will receive an error when you try saving to the database.
The error occurs due to the difference between the structure of the "__MigrationHistory" table used by EF5 and EF6.
To use EF5 and EF6 applications against the same database without any errors, run the following command in the database:
drop table "__MigrationHistory"