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>
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
.