<system.data>
<DbProviderFactories>
<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"/>
<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"/>
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="northwindEFEntities" connectionString="data source=.\northwindEF.db" providerName="System.Data.sqlite"/>
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.sqlite" type="System.Data.sqlite.EF6.sqliteProviderServices,System.Data.sqlite.EF6"/>
</providers>
</entityFramework>
因为用到了EF,所以这里的entityFramework配置里面的invariantName与connectionStrings里面的providerName都要对应为DbProviderFactories里面注册的名字invariant="System.Data.sqlite",否则会提示没有注册System.Data.sqlite。
并且<DbProviderFactories>节必须有,否则当目标计算机没有GAC注册System.Data.sqlite,会提示找不到。。。
原文链接:https://www.f2er.com/sqlite/200572.html