【问题标题】:SQLite error no such column using Entity FrameworkSQLite 错误没有使用实体框架的此类列
【发布时间】:2012-07-20 15:50:52
【问题描述】:

我正在尝试查找仅出现在某些客户端计算机上的错误,当然我们无法在内部重现该错误。抛出的InnerException

SQLite 错误没有这样的列:Extent1.UserDefinedPid

找不到的列是SQLite数据库中这样定义的位域:

[UserDefinedPid] bit NOT NULL DEFAULT 0

EDMX 文件包含这个定义(只是部分内容):

<EntityType Name="Parameter">
  <Key>
    <PropertyRef Name="ParameterID" />
  </Key>
  <Property Type="Int64" Name="ParameterID" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
  ...
  <Property Type="Boolean" Name="UserDefinedPid" Nullable="false" />
  ...
</EntityType>

我们已经确认了相同的 SQLite 数据库文件,并且正在加载正确的 System.Data.SQLiteSystem.Data.SQLite.Linq dll,但由于某些奇怪的原因,一些机器似乎认为此列丢失了。

我们使用的数据库是加密的,我们有一个应用程序的 app.config 文件,以确保 SQLite 的其他安装不会干扰应用程序。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections></configSections>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
  <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" />
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Data.SQLite" culture="neutral" publicKeyToken="db937bc2d44ff139" />
        <bindingRedirect oldVersion="1.0.0.0 - 2.0.0.0" newVersion="1.0.66.0" />
      </dependentAssembly>
     </assemblyBinding>
  </runtime>
</configuration>

我不知道为什么这在某些机器上会失败。任何想法都非常感谢:-)

【问题讨论】:

  • 列的名称是什么?任何有趣的事情,例如它是否包含重音字符?
  • @JonSkeet 在某些机器上抛出错误的列的名称是 UserDefinedPid。除了它在某些机器上失败但在其他机器上失败之外,没有什么特别有趣的。有问题的机器正在运行 Windows 7 Professional SP1 64bit。

标签: c# linq entity-framework sqlite


【解决方案1】:

我强烈怀疑您正在使用 System.Data.SQLite 的 quite old version

或许你可以试试here找到的最新版本。

一旦你这样做了,app.config 文件将不再需要这个:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite" culture="neutral" publicKeyToken="db937bc2d44ff139" />
    <bindingRedirect oldVersion="1.0.0.0 - 2.0.0.0" newVersion="1.0.66.0" />
  </dependentAssembly>
 </assemblyBinding>

我有点不清楚你提到的加密问题。您是使用提供给SQLiteConnection 连接对象的密码进行加密,还是使用SEE extension

【讨论】:

  • 我们使用的是 2010 年 4 月的版本 1.0.66.0。我们尝试在问题计算机上使用最新版本 1.0.81.0,但它立即崩溃并且根本无法打开连接(想想加载数据提供者时出错)。我们在数据库上使用 RSA 加密来保护我们的 IP。无需担心加密,但如果有可能导致问题,我想确保我注意到了这一事实。
  • @BrianWenhold:我对此的看法是找出新版本的问题并使用它,然后再进一步解决您现在遇到的问题;如果需要,也许可以提出一个新问题。
猜你喜欢
  • 2015-11-26
  • 2014-08-10
  • 1970-01-01
  • 1970-01-01
  • 2018-06-08
  • 1970-01-01
  • 1970-01-01
  • 2013-04-13
  • 2010-10-30
相关资源
最近更新 更多