Estou em um projeto WPF usando algumas práticas de MVVM, estou usando Entity Framework database first e a connection string já está no app.config, já segui todos os procedimentos que li em diversas questões porém na view aparece essa mensagem no DataContext
Abaixo a connectionstring que já está no app.config
<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" />
O Contexto do banco de dados
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; }
}
Procedimentos que já fiz e não funcionaram:
- Remover o "name" do Contexto;
- Colocar a connection string em outro arquivo
config
e fazer o link noapp.config
; - Comentar
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>
App1.config
completo. Pode por favor atualizar sua pergunta?App1.config
? Devia se chamar apenasApp.config
. Ao fazer o Build do seu projeto, ele passa a chamarSeuProjeto.config
.