9

I use .accdb file. I created class

using System.Data.Entity;

    class MSADbContext:DbContext
    {
        public DbSet<Product> Products { get; set; }
    }

and add connectionString

<add name="MSADbContext" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SportsStore.accdb" providerName="System.Data.OleDb"/>

After first query to DB I get the ProviderIncompatibleException: "calling "get_ProviderFactory" in repository typeOf "System.Data.OleDb.OleDbConnection" returns null"

Stalli
  • 374
  • 2
  • 5
  • 16

3 Answers3

9

Your connection-string would be for an .mdb (Access 2003-) file. Check connection strings here

You need the ACE OLEDB provider. Standard Security:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;
Persist Security Info=False;

However, read this thread first:

Entity Framework does not support OLEDB connections, so your connection string will not work. It is practically impossible to get Entity Framework to collaborate with MS Access.

practically impossible is very compelling.

Community
  • 1
  • 1
Andy G
  • 19,232
  • 5
  • 47
  • 69
9

OLEDB cannot support entity framework because entity framework needs that the entity framework provider generates the right queries for the specific database (while OLEDB is general DB access). You need a specific provider for Microsoft Access.

You can find a Microsoft Access Entity Framework Provider here https://jetentityframeworkprovider.codeplex.com/

EDIT
The Access EF provider is now hosted on GitHub
https://github.com/bubibubi/JetEntityFrameworkProvider

bubi
  • 6,414
  • 3
  • 28
  • 45
  • Given the announcement that [CodePlex will be shutting down](https://blogs.msdn.microsoft.com/bharry/2017/03/31/shutting-down-codeplex/) will you be moving your project to GitHub? – Gord Thompson Apr 03 '17 at 12:49
  • 2
    I didn't see it. I will move it to github. Thanks! – bubi Apr 04 '17 at 17:50
0

I know that this question was asked long ago but it seems that the author of original package (JetEntityFrameworkProvider) has developed a new Access EF provider called EntityFrameworkCore.Jet

Budo Zindovic
  • 805
  • 5
  • 11