Skip to content

No Entity Framework provider found for the ADO.NET provider with invariant name 'JetEntityFrameworkProvider' #53

@it19862

Description

@it19862

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
2020-07-20_21-04-13

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();
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions