对于 3d 方应用程序插件,有必要使用 SQLite 实体框架数据库优先方法。我搜索了整个互联网,包括添加不带 App.Config 的 DbProviderFactory https://stackoverflow.com/questions/1117683/add-a-dbproviderfactory-without-an-app-config, 使用 Entity Framework 6 和 SQLite 的问题 https://stackoverflow.com/questions/20460357/problems-using-entity-framework-6-and-sqlite以及许多其他的。我尝试以不同的方式和组合使用它们,但没有任何帮助:
“未处理的类型异常
mscorlib.dll 中发生“System.Data.Entity.Core.MetadataException”。
附加信息:指定的架构无效。错误:
AutosuggestModel.ssdl (2,2):错误 0152:没有实体框架提供程序
找到具有不变名称的 ADO.NET 提供程序
'系统.Data.SQLite.EF6'。确保提供商已在
应用程序配置文件的“entityFramework”部分。”
解决方案中有一个测试控制台应用程序。使用这个最小的 App.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>
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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>
连接字符串已经在代码中实现了。使用的包有:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="System.Data.SQLite" version="1.0.98.1" targetFramework="net452" />
<package id="System.Data.SQLite.Core" version="1.0.98.1" targetFramework="net452" />
<package id="System.Data.SQLite.EF6" version="1.0.98.1" targetFramework="net452" />
<package id="System.Data.SQLite.Linq" version="1.0.98.1" targetFramework="net452" />
</packages>
请提供所有必需的代码并指定插入位置。提前致谢。