I'm in a WPF project using some MVVM practices, I'm using the Entity Framework database first and the connection string is already in the app.config, I've already followed all the procedures I've read on several issues but in the view this message appears in the DataContext
Belowtheconnectionstringthatisalreadyintheapp.config
<addname="TimerEntities" connectionString="metadata=res://*/Timer.csdl|res://*/Timer.ssdl|res://*/Timer.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=C:\Users\Angelica\Documents\DB\Timer.sdf;Max Database Size=4091""
providerName="System.Data.EntityClient" />
The Database Context
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class TimerEntities : DbContext
{
public TimerEntities()
: base("name=TimerEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<CAIXA> CAIXAS { get; set; }
public virtual DbSet<CLIENTE> CLIENTES { get; set; }
public virtual DbSet<ORDEM> ORDEM { get; set; }
public virtual DbSet<PACOTE> PACOTES { get; set; }
public virtual DbSet<TEMPO> TEMPOS { get; set; }
}
Procedures that I have already done and did not work:
config
file and link to app.config
; throw new UnintentionalCodeFirstException();
; <?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="TimerEntities" connectionString="metadata=res://*/Timer.csdl|res://*/Timer.ssdl|res://*/Timer.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=C:\Users\Angelica\Documents\DB\Timer.sdf;Max Database Size=4091""
providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<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>
</entityFramework>
<system.data>
<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>
</system.data>
</configuration>