EntityFramework database provider could not be found

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
oana
Posts: 7
Joined: Tue 15 Nov 2016 11:37

EntityFramework database provider could not be found

Post by oana » Tue 15 Nov 2016 11:46

Hi,

I installed dotConnect for Postgresql Professional, trial version and when I want to create my edmx, I get this error: "Your project references the latest version of the Entity Framework; however, an Entity Framework data provide compatible with this version could not be found for your data connection. If you have already installed a compatable provider..."

I have installed EntityFramework 6.1.3 (the latest one) via nuget.
I have referenced these dll-s in my project: Devart.Data, Devart.Data.Postgresql, Devart.Data.Postgresql.Entity (6).

My App.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity, Version=7.6.763.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.PostgreSql" />
<add name="dotConnect for Postgresql" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for Postgresql" type="Devart.Data.PostgreSql.PostgreSqlProviderFactory, Devart.Data.PostgreSql, Version=7.6.763.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
</configuration>

I also modified Version=7.6.763.0 from <entity framework> with Version=7.6.763.6 after rebuilding app.

Could you, please help? Thanks.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: EntityFramework database provider could not be found

Post by Shalex » Tue 15 Nov 2016 13:10

Starting from v7.5, there was EF assembly name change: viewtopic.php?f=3&t=33573 > the Entity Framework Assembly Name Change section.

Please replace

Code: Select all

<entityFramework>
  <providers>
    <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity, Version=7.6.763.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  </providers>
</entityFramework>
with

Code: Select all

<entityFramework>
  <providers>
    <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity.EF6, Version=7.6.763.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  </providers>
</entityFramework>

oana
Posts: 7
Joined: Tue 15 Nov 2016 11:37

Re: EntityFramework database provider could not be found

Post by oana » Wed 16 Nov 2016 07:44

Thanks a lot, it worked. But after creating the edmx I get this error:

Code: Select all

Error	5	An Exception was thrown while running the transformation code. The process cannot continue.  The following Exception was thrown:
System.BadImageFormatException: Could not load file or assembly 'Microsoft.VisualStudio.TextTemplating.VSHost.12.0.dll' or one of its dependencies. 
An attempt was made to load a program with an incorrect format.
File name: 'Microsoft.VisualStudio.TextTemplating.VSHost.12.0.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.LoadWithPartialNameHack(String partialName, Boolean cropPublicKey)
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.PrepareTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host)
   at Microsoft.VisualStudio.TextTemplating.Engine.CompileAndPrepareRun(String generatorCode, ITextTemplatingEngineHost host, TemplateProcessingSession session, IDebugTransformationRunFactory runFactory)

	C:\Proiecte\mille doctconnect\trunk\MillefioriProd.Data\ModelMillefioriProd.tt	0	0	MillefioriProd.Data
In the edmx file I can see all the tables from the database, but the generated .cs file for the edmx says: ErrorGeneratingOutput
No classes were generated for my tables.

oana
Posts: 7
Joined: Tue 15 Nov 2016 11:37

Re: EntityFramework database provider could not be found

Post by oana » Wed 16 Nov 2016 07:50

Actually there are two errors. The first one is:

Code: Select all

Error	12	There was a problem loading the assembly 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.VSHost.12.0\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.VSHost.12.0.dll' The following Exception was thrown:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.VSHost.12.0\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.VSHost.12.0.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.VSHost.12.0\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.VSHost.12.0.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.AttemptAssemblyLoad(String assemblyName)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: EntityFramework database provider could not be found

Post by Shalex » Thu 17 Nov 2016 14:48

These errors are not related to dotConnect for PostgreSQL.

As a workaround, we recommend you to use Entity Developer (Devart Entity Model, *.edml) instead of EDM Designer (ADO.NET Entity Data Model, *.edmx). It is adjusted for working with PostgreSQL and has an advanced functionality: http://www.devart.com/entitydeveloper/ed-vs-edm.html. Additionally, Entity Developer adds registration of EF6 provider in app.config automatically.

Post Reply