Throwing this up here since the author asks for help requests to go to StackOverflow.
Have an existing app in progress, originally wrote to SQL Server. Sadly now there is a very old Access Database that I must talk to. Trying to use JetEntityFramework to help me out so I don't need to make wholesale substitutions. Out of the gate, this exception I throw. I suspect a problem with web.config as the documentation for setting this up correctly is sparse.
Error
System.InvalidOperationException was unhandled by user code
HResult=-2146233079 Message=The 'Instance' member of the Entity Framework provider type 'JetEntityFrameworkProvider.JetProviderFactory, JetEntityFrameworkProvider, Version=1.2.4.0, Culture=neutral, PublicKeyToken=756cf6beb8fe7b41' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Here is the relevant snippet of my web.config (was asked to change the actual name of the DBContext and MDB file)
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="JetEntityFrameworkProvider" type="JetEntityFrameworkProvider.JetProviderFactory, JetEntityFrameworkProvider"/>
</providers>
</entityFramework>
<connectionStrings>
<add name="MyDBContext"
connectionString="Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\MyAccessDB.MDB"
providerName="JetEntityFrameworkProvider.JetConnection" />
</connectionStrings>
<system.data>
<DBProviderFactories>
<remove invariant="JetEntityFrameworkProvider"/>
<add invariant="JetEntityFrameworkProvider"
name="Jet Entity Framework Provider"
type="JetEntityFrameworkProvider.JetProviderFactory, JetEntityFrameworkProvider"/>
</DBProviderFactories>
</system.data>
In your example the provider uses JetEntityFrameworkProvider.JetProviderFactory
as its type. This caused the above exception because it does not inherit from System.Data.Entity.Core.Common.DbProviderServices
. From the video tutorial and also from inspecting the source code JetEntityFrameworkProvider.JetProviderServices
is the type needed for the provider.
Based on the tutorial from the project site, check the following configuration that was shown as an example.
<connectionStrings>
<add name="MyDBContext"
connectionString="Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\MyAccessDB.MDB"
providerName="JetEntityFrameworkProvider" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider
invariantName="JetEntityFrameworkProvider"
type="JetEntityFrameworkProvider.JetProviderServices, JetEntityFrameworkProvider"/>
</providers>
</entityFramework>
<system.data>
<DBProviderFactories>
<remove invariant="JetEntityFrameworkProvider"/>
<add
invariant="JetEntityFrameworkProvider"
name="Jet Entity Framework Provider"
description="Jet Entity Framework Provider"
type="JetEntityFrameworkProvider.JetProviderFactory, JetEntityFrameworkProvider"/>
</DBProviderFactories>
</system.data>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With