0

I can't figure out what to do with this exception and would appreciate help. I basically have SQL CE database which I created. I also created and a table and data in it. Then I want to load data from that table using Entity framework in ASP MVC4 project. Here is my code and web config, but I get exception as stated below (see image)

Controller:

 public class EmployeeController : Controller
 {
        //
        // GET: /Employee/

        public ActionResult Index()
        {

            EmployeeContext e = new EmployeeContext();
            var list = e.Employeeslist.ToList(); // here is the exception

Model classes:

 public class EmployeeContext: DbContext
 {
        public DbSet<Employee> Employeeslist { get; set; }
 }

[Table("Employees")]
public class Employee
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Gender { get; set; }
    public string City { get; set; }
}

My connection string

 <connectionStrings>
    <add name="EmployeeContext" connectionString="Data Source=c:\users\g\documents\visual studio 2012\Projects\TestMVCApp\TestMVCApp\App_Data\EmployeeDB.sdf" providerName="System.Data.SqlServerCe.4.0" />
  </connectionStrings>

This is the exception I get: enter image description here

I also installed from nuget packages EntityFramework.SqlServerCompact package for entity framework but still I get this exception. Any help appreciated!

Also here is some data from web config:

<entityFramework>
    <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>
  </entityFramework>

There is also warning (blue line over providers-not sure if it is warning or what) says entityFramework has invalid child nodes about providers.

  • Maybe You download different version of this provider ? – MajkeloDev Oct 13 '15 at 20:01
  • @MajkeloDev: Which version to use? –  Oct 13 '15 at 20:04
  • @MajkeloDev: I believe I have correct version. EF is 6.smth and the EF.SQLCompact package was 4.0 but referring to same EF version –  Oct 13 '15 at 20:24
  • Looks to be a dup of this: http://stackoverflow.com/questions/6865249/unable-to-find-the-requested-net-framework-data-provider-it-may-not-be-install – Shockwave Oct 13 '15 at 20:26
  • @Shockwave: No please read my question carefully and answer of that question –  Oct 13 '15 at 20:33

1 Answers1

0

Install the SQL Server CE runtime. For using this library, there are probably portions needed that must be in the GAC and not just your project.

http://www.microsoft.com/en-us/download/details.aspx?id=17876

Xavier J
  • 4,326
  • 1
  • 14
  • 25
  • I've done that it told me SQL CE already installed, so this doesn't help –  Oct 13 '15 at 20:37