JetEntityFrameworkProvider
JetEntityFrameworkProvider copied to clipboard
No Entity Framework provider found for the ADO.NET provider with invariant name 'JetEntityFrameworkProvider'
Error. No Entity Framework provider found for the ADO.NET provider with invariant name 'JetEntityFrameworkProvider'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. "
Question: How do I resolve the error?
Used by
- Windows - 7x64;
- Microsoft Visual Studio Community 2019 - Version 16.6.3;
Description. I am trying to connect to MS Access database - db_test_01.accdb. I have created a console application. I am using the instruction: https://www.youtube.com/watch?v=mI0un8jjqL8
I get an error: see the "Error" section above.
Picture
Code App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<connectionStrings>
<add name="DefaultConnection"
connectionString="Provider=Microsoft.ACE.OleDB.12.0;Data source=c:\test\csharp\vs\db\db_test_01.accdb"
providerName="JetEntityFrameworkProvider"/>
</connectionStrings>
</configuration>
Person.cs
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ConsoleApp
{
class Person
{
public Person()
{
OwnerCars = new List<Car>();
}
public int Id { get; set; }
[MaxLength(10)]
public string Name{ get; set; }
public virtual ICollection<Car> OwnerCars { get; set; }
}
}
Car.cs
using System.ComponentModel.DataAnnotations;
namespace ConsoleApp
{
class Car
{
public int Id { get; set; }
[MaxLength(10)]
public string Name { get; set; }
public virtual Person Owner { get; set; }
}
}
Context.cs
using System.Data.Entity;
namespace ConsoleApp
{
class Context : DbContext
{
public Context() : base("DefaultConnection")
{
}
public DbSet<Car> Cars{ get; set; }
public DbSet<Person> People { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Person>()
.HasMany(_ => _.OwnerCars)
.WithOptional(_ => _.Owner);
}
}
}
Program.cs
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
JetEntityFrameworkProvider.JetConnection.ShowSqlStatements = true;
using (var context = new Context())
{
context.Cars.Count();
}
Console.ReadLine();
}
}
}
This is a section of an App.Config. Could you check if your is similar?
</configuration>
<entityFramework>
<providers>
<provider invariantName="JetEntityFrameworkProvider" type="JetEntityFrameworkProvider.JetProviderServices, JetEntityFrameworkProvider" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</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>
</configuration>
@bubibubi
This is a section of an App.Config. Could you check if your is similar?
</configuration> <entityFramework> <providers> <provider invariantName="JetEntityFrameworkProvider" type="JetEntityFrameworkProvider.JetProviderServices, JetEntityFrameworkProvider" /> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </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> </configuration>
Question: How to connect these ("App.config" -bubibubi) + "App.config" (My)?
I do not understand you
My "App.config" (My).
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> </startup> <connectionStrings> <add name="DefaultConnection" connectionString="Provider=Microsoft.ACE.OleDB.12.0;Data source=c:\test\csharp\vs\db\db_test_01.accdb" providerName="JetEntityFrameworkProvider"/> </connectionStrings> </configuration>
You are providing "App.config" -bubibubi.
</configuration>
<entityFramework>
<providers>
<provider invariantName = "JetEntityFrameworkProvider" type = "JetEntityFrameworkProvider.JetProviderServices, JetEntityFrameworkProvider" />
<provider invariantName = "System.Data.SqlClient" type = "System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</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>
</configuration>
@bubibubi The topic is closed. Thank.