Entity Framework 6.1.3 and SQL Server CE 4.0 - No Entity Framework provider found

ef-database-first entity-framework-6 git sql-server-ce-4

Question

PROBLEM: I had a website that was working with my local dev machine (VS2013, EF6.1.3, SQl Server CE 4.0, EF Tools installed). I maintain the website using a git repo locally and in VS OnLine.

I am at a different (temporary) location with a new machine. I fetched the website from my git repo down to this new machine. All seemed to work OK (could see intellisense in the code using the entities in the model). The SQL CE 4.0 database (StarterSite) works fine in the SQL CE Toolbox. I can see the entities in the model (edmx), originally built using database-first approach.

However, when I tried to update the model from the SQL CE 4.0 database, I got this error: "An exception of type 'System.ArgumentException' occurred while attempting to update from the database. The exception message is: 'Unable to convert runtime connection string to its design-time equivalent. The libraries required to enable Visual Studio to communicate with the database for design purposes (DDEX provider) are not installed for provider 'System.Data.SqlServerCe.4.0'. Connection string: Data Source="C:\Users\\Documents\Visual Studio 2013\WebSites\NakedEF\App_Data\StarterSite.sdf"'".

I cannot seem to get my Ef 6.1.3 Model to work. I keep getting that error. When I try to run the site, I get a metadata exception: An exception of type 'System.Data.Entity.Core.MetadataException' occurred in mscorlib.dll but was not handled in user code.
Additional information: Schema specified is not valid. Errors: App_Code.Model.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. 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. But I have installed the provider via nuget: and included it in my entityFramework section (see web.config excerpts below)

Just out of curiosity, I built a new website (razor3 template) and added an entity model to the site. Worked fine without a hitch.

ENVIRONMENT On this new machine I have VS 2013 I have installed Entity Framework Tools 6.1.3 on the machine, I used nuget to install EF 6.1.3, EF SQL Server CE 4.0 provider, and SQL Server CE 4.0.

Here is the package.config for the website where EF and SQL CE are not working:

    <packages>

      <package id="DotNetOpenAuth.AspNet" version="4.1.4.12333" targetFramework="net
    45" />

      <package id="DotNetOpenAuth.Core" version="4.1.4.12333" targetFramework="net45
    " />

      <package id="DotNetOpenAuth.OAuth.Consumer" version="4.1.4.12333" targetFramew
    ork="net45" />

      <package id="DotNetOpenAuth.OAuth.Core" version="4.1.4.12333" targetFramework=
    "net45" />

      <package id="DotNetOpenAuth.OpenId.Core" version="4.1.4.12333" targetFramework
    ="net45" />
      <package id="DotNetOpenAuth.OpenId.RelyingParty" version="4.1.4.12333" targetF
    ramework="net45" />

      <package id="EntityFramework" version="6.1.3" targetFramework="net45" />

      <package id="EntityFramework.SqlServerCompact" version="6.1.3" targetFramework
    ="net45" />

      <package id="jQuery" version="1.10.2" targetFramework="net45" />


      <package id="jQuery.UI.Combined" version="1.10.3" targetFramework="net45" />


      <package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />

      <package id="knockoutjs" version="2.3.0" targetFramework="net45" />

      <package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" /
    >

      <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramewor
    k="net45" />

      <package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45
    " />

      <package id="Microsoft.AspNet.WebPages.Data" version="3.2.2" targetFramework="
    net45" />

      <package id="Microsoft.AspNet.WebPages.OAuth" version="3.2.2" targetFramework=
    "net45" />

      <package id="Microsoft.AspNet.WebPages.WebData" version="3.2.2" targetFramewor
    k="net45" />

      <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.2" targetFr
    amework="net45" />

      <package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework
    ="net45" />

      <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="
    net45" />

      <package id="Modernizr" version="2.6.2" targetFramework="net45" />

      <package id="RestSharp" version="105.0.1" targetFramework="net45" />

      <package id="Twilio" version="3.6.29" targetFramework="net45" />

      <package id="Twilio.WebMatrix" version="3.1.4" targetFramework="net45" />

      <package id="WebGrease" version="1.5.2" targetFramework="net45" />

    </packages>

relevant bin directory contents

    /bin/EntityFramework.dll

    /bin/EntityFramework.SqlServer.dll

    /bin/EntityFramework.SqlServerCompact.dll

    /bin/System.Data.SqlServerCe.dll

relevant web.config settings:

<DbProviderFactories>

  <remove invariant="System.Data.SqlServerCe.4.0" />

  <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

</DbProviderFactories>

<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">

  <parameters>

    <parameter value="System.Data.SqlServerCe.4.0" />

  </parameters>

</defaultConnectionFactory>

<providers>

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

</providers>

<connectionStrings>

<add name="StarterSite" connectionString="Data Source=|DataDirectory|\StarterSite.sdf" providerName="System.Data.SqlServerCe.4.0" />

  <add name="ModelEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlServerCe.4.0;provider connection string='Data Source=&quot;C:\Users\<MyUserName>\Documents\Visual Studio 2013\WebSites\NakedEF\App_Data\StarterSite.sdf&quot;'" providerName="System.Data.EntityClient" />


HELP REQUEST: When I get into these assemblies and refferences and dlls, I am very quickly in over my head.

What am I doing wrong here? Can someone help me get this website to work in the new machine (I am unable to go back to the original dev mnachine and run the clone there.

1
2
4/20/2015 9:34:27 PM

Accepted Answer

You need to install the SQL Server Compact Toolbox on the new dev machine, it installs the DDEX provider for you. (You may have to go to the About screen in the Toolbox and clikc the DDEX install button, then restart VS)

4
4/21/2015 6:02:41 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow