0
EF(6.1.3)とSQLiteに基づくデータサービスを実装しようとしています。私はそれが非常に小さなテストアプリで働いているが、この経験を複製することはできません。私のデータサービスクラスライブラリには、system.data.sqlite ....コンポーネントがロードされています。私はまた、SQLite.CodeFirstを読み込んだので、EF 6.1.3の作成関数はSQLiteのために完了していません。 しかし、データサービスが呼び出されたときに私が得るエラーは次のとおりです。SQLite Entity Framework ADO.NETエラー
System.InvalidOperationException occurred HResult=0x80131509 Message=No Entity Framework
provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'.
Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
私は、app.configファイルで、この必須だと思いますが、いただきました構成と間違って見つけるように見えることはできません。
ここに、コンテキストクラスのコードがあります。
public class IRMContext : DbContext
{
public DbSet<Operator> Operators { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var sqlLiteInit = new SqliteDropCreateDatabaseWhenModelChanges<IRMContext>(modelBuilder);
Database.SetInitializer<IRMContext>(sqlLiteInit);
}
}
そして、app.configファイル。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<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.6.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.96.0" newVersion="1.0.96.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<connectionStrings>
<add name="IRMContext" connectionString="Data Source=C:\IRManager\IRManager.sqlite" providerName="System.Data.SQLite"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v13.0"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</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"/>
<remove invariant="System.Data.SQLite"/>
<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>
</system.data>
</configuration>
何か助けを借りていただければ幸いです。ありがとう
ここにいくつかのヒントがあります:https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider – ErikEJ