小编cos*_*shu的帖子

没有 App.config 的 SQLite 实体框架

有必要对 3d 方应用程序插件使用 SQLite 实体框架数据库优先方法。我在互联网上搜索了所有内容,包括添加没有 App.Config 的 DbProviderFactory、使用实体框架 6 和 SQLite 的问题等等。我试图以不同的方式和组合使用它们,但没有任何帮助:

“mscorlib.dll 中发生了类型为 'System.Data.Entity.Core.MetadataException' 的未处理异常。附加信息:指定的架构无效。错误:AutosuggestModel.ssdl (2,2):错误 0152:没有实体框架提供程序为具有不变名称“System.Data.SQLite.EF6”的 ADO.NET 提供程序找到。确保该提供程序已在应用程序配置文件的“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> …
Run Code Online (Sandbox Code Playgroud)

.net c# sqlite entity-framework app-config

5
推荐指数
1
解决办法
3152
查看次数

标签 统计

.net ×1

app-config ×1

c# ×1

entity-framework ×1

sqlite ×1