visual studio net framework for first code and c# entity-framework sqlite entity-framework-6

c# - net - sqlite visual studio 2008



''No se ha encontrado ningĂșn proveedor de Entity Framework'' para EF 6 y SQLite 1.0.96.0 (6)

Me doy cuenta de que ya hay varias preguntas similares sobre este tema, pero muchas de ellas provienen de una versión anterior de SQLite que, por lo que sé, no era totalmente compatible con EF 6. He intentado innumerables sugerencias de estos hilos y estoy haciendo algo mal o algo debe haber cambiado.

Estoy usando VS 2013, apuntando a .NET 4.5.1 y he instalado el paquete sqlite-netFx451-setup-bundle-x86-2013-1.0.96.0.exe desde la página de descarga de system.data.sqlite.org , así como el Paquete System.Data.SQLite EF6 del NuGet Manager (que instala EF6).

A continuación se muestra mi archivo App.config actual (está prácticamente intacto, salvo que intenté agregar las variables de la Versión, Cultura y Clave pública al tipo):

<?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" /> </configSections> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /> </startup> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" /> </providers> </entityFramework> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite.EF6" /> <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" /> </DbProviderFactories> </system.data> </configuration>

Y mi packages.config:

<?xml version="1.0" encoding="utf-8"?> <packages> <package id="EntityFramework" version="6.1.2" targetFramework="net451" /> <package id="System.Data.SQLite.EF6" version="1.0.96.0" targetFramework="net451" /> </packages>

Si hago algo como intentar generar una base de datos desde el modelo, veo el siguiente error:

No se ha encontrado ningún proveedor de Entity Framework para el proveedor de ADO.NET con el nombre invariable ''System.Data.SQLite.EF6''. Asegúrese de que el proveedor esté registrado en la sección ''entityFramework'' ...

He intentado meter el archivo App.config y agregar otros proveedores y proveedores como han sugerido los viejos hilos, pero fue en vano.

¿Cómo soluciono este problema? ¡Cualquier ayuda es muy apreciada!

Editar: logré que funcionara lo suficientemente bien como para usar una primera base de datos. Aquí están las partes relevantes de mi archivo App.config:

<providers> <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> </providers> <DbProviderFactories> <remove invariant="System.Data.SQLite" /> <remove invariant="System.Data.SQLite.EF6" /> <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> </DbProviderFactories>

Estoy usando EF 6.1.2 y System.Data.SQLite 1.0.96.0.


Aquí hay una aplicación en funcionamiento.config

<?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" /> </configSections> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <entityFramework> <providers> <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/> </providers> </entityFramework> <connectionStrings> <!-- use AppDomain.SetData to set the DataDirectory --> <add name="MapDbConnectionStr" connectionString="Data Source=|DataDirectory|MapDb.sqlite" providerName="System.Data.SQLite" /> </connectionStrings> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite.EF6" /> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> </DbProviderFactories> </system.data> </configuration>



Finalmente lo conseguí también trabajo

Estoy usando: EF 6.1.3 http://www.microsoft.com/en-us/download/details.aspx?id=40762 y System.Data.SQLite 1.0.96.0 sqlite-netFx451-setup-bundle-x86 -2013-1.0.96.0.exe

Seguí la descripción escrita en: Base de datos primero crea el modelo de entidad de marco 6.1.1 usando system.data.sqlite 1.0.93 (en esta descripción se instala un paquete nuget de entidad framwork -i también lo hizo)

Para el archivo app.config utilicé estas soluciones: https://.com/a/24324212/885349 (escrito por tomexou)

Finalmente SQLite Connector no se mostró en ADO.Net Entity Data Model Mapper

El enlace que faltaba era la carpeta / bin. Tuve que establecer la configuración "Copiar local" = verdadero para las siguientes dlls:

  • SQLite.Designer
  • System.Data.SQLite
  • System.Data.SQLite.EF6
  • System.Data.SQLite.Linq

Solo para completarlo: agregado a través de Nuget y también en la carpeta / bin

  • Marco de la entidad
  • EntityFramework.SqlServer

Y se mostró la conexión SQLite ...


Pruebe estos ajustes:

<providers> ... <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/> </providers> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite.EF6" /> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> </DbProviderFactories> </system.data>

Ver Entity Framework 6 + SQLite


Resolví el mismo error con solo agregar una sola línea en App.config

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>

PD: agregue provider a <configuration> >> <entityFramework> >> <providers>


public class EFConfiguration : DbConfiguration { public EFConfiguration() { SetDefaultConnectionFactory(new LocalDbConnectionFactory("v.11")); //HACK var EF6ProviderServicesType = typeof(System.Data.SQLite.EF6.SQLiteProviderFactory).Assembly.DefinedTypes.First(x => x.Name == "SQLiteProviderServices"); var EF6ProviderServices = (DbProviderServices)Activator.CreateInstance(EF6ProviderServicesType); SetProviderServices("System.Data.SQLite.EF6", EF6ProviderServices); SetProviderServices("System.Data.SqlClient", System.Data.Entity.SqlServer.SqlProviderServices.Instance); SetProviderFactory("System.Data.SQLite.EF6", System.Data.SQLite.EF6.SQLiteProviderFactory.Instance); SetProviderFactory("System.Data.SQLite", System.Data.SQLite.SQLiteFactory.Instance); } }