SubSonic,SQLite和无法找到数据提供程序?

3

我开始使用SubSonic。我想将我的数据库更改为sqlite,我在配置文件中有以下内容:

  <connectionStrings>
      <add name="NorthwindSQLite"
       connectionString="Data Source=C:\unzipped\WindowsFormsApplication1\my.db"
       providerName="System.Data.SQLite"/>
  </connectionStrings>

我遇到了异常

A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Unable to find the requested .Net Framework Data Provider.  It may not be installed.

我在参考资料中有SQLite参考文献。那么我该如何解决这个问题?

2个回答

4
如果你正在使用Visual Studio,尝试在服务器资源管理器中使用System.Data.SQLite创建一个数据库连接。如果System.Data.SQLite提供程序不在提供程序列表中,则安装或重新安装它。然后检查你是否能够在Visual Studio中打开和查看表数据。如果这个步骤可行,SubSonic 2.2应该能够与SQLite文件一起工作。我使用了一个较新的SubSonic SQLite数据提供程序,它在SubSonic的Github存储库中,并且对我来说似乎效果更好。但是它不会生成许多对多代码。
在已部署的应用程序中,你无需单独安装提供程序。

我从没意识到需要单独安装提供程序。不知为何,我认为添加引用会使项目将其用作提供程序(或什么...)。问题解决了,我的所有代码都可以工作。 - user34537
由于它已经编译过了,但在运行时引发了异常,这是否意味着SQLite提供程序必须在生产环境中进行“安装”?我认为“无需安装”是SQLite的优点之一。 - flipdoubt
1
从SQLite的readme.txt文件和https://dev59.com/F3NA5IYBdhLWcg3wBpLs#1118089中,我发现您可以在配置文件中添加DbProviderFactories。 - flipdoubt

1

Subsonic 的哪个版本?

我的 SQLite 工作提供程序部分如下:

<add name="Local" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="MyConn" generatedNamespace="X.Data" stripTableText="tbl" />

我的连接字符串看起来像这样

<add name="MyConn" connectionString="Data Source=C:\data.db;Version=3;"/>

希望这可以帮到你 :-)

忘记在 Subsonic 2.0 中添加它 - 我还没有在 Subsonic 3 中使用过 SQLite。 - Doug

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接