No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'

后端 未结 12 2282
失恋的感觉
失恋的感觉 2020-12-05 22:44

I got the following error when I used sqlce 4.0 with entityframework 6.0

No Entity Framework provider found for the ADO.NET provider with invariant name \'Sy         


        
相关标签:
12条回答
  • 2020-12-05 23:19

    Within Visual Studio, all the .dll files that exist in _bin_deployableAssemblies folder need to be set to Build Action : none

    All the .dll's for me were set to content.

    This is what I set it to, and it worked straight after:

    0 讨论(0)
  • 2020-12-05 23:20

    To resolve this problem

    Visual Studio Menu -> Tools -> NuGet Package Manager - > Manage NuGet Packages for Solution

    Select 'Browse' Tab and search for following 'EntityFramework.SqlServerCompact'

    Install it.

    It should work.

    0 讨论(0)
  • 2020-12-05 23:22

    After installing the EntityFramework.SqlServerCompact nuget package, check that your app.config contains the following (as per @ErikEJ's comment above):

    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
    </providers>
    

    (You can leave the line for SqlClient even though you don't really need it.)

    0 讨论(0)
  • 2020-12-05 23:27

    For me, because the programmer is not only one, some programmer is already install EntityFramework.SqlServerCompact, but when I pull in my PC and RUN shows above error message, then I just Uninstall and install again.

    0 讨论(0)
  • 2020-12-05 23:30

    My issue was the unit tests. You likely only installed the Entity framework for your project, but not your unit tests. To do so:

    Right click "Solution" in Solution Explorer (not your project's name)

    Click "Manage NuGet Packages"

    Search for EntityFramework and press it

    You will probably not see a tick next to [Project Name].Tests

    0 讨论(0)
  • 2020-12-05 23:36

    ErikEJ has pointed this out, but I'd like to highlight the fact, you MUST remember to install the Nuget package

    EntityFramework.SqlServerCompact
    

    I tried following the recommended answer, but didn't realise I didn't have the required NuGet package the App.config was referencing.

    0 讨论(0)
提交回复
热议问题