我想使用 SubSonic,因为它说它易于使用且节省时间。
经过 3 小时尝试正确获取 MySQL 的连接字符串后,我将要放弃它。
Building configuration from C:\Documents and Settings\user\My Documents\Visual Studio 2
008\Projects\ConfigurationItems\ConfigurationItemsMVC\Web.config
Adding connection to MySqlDataProvider
ERROR: Trying to execute generate
Error Message: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
我无法改变这个:错误消息:System.ArgumentException:初始化字符串的格式不符合从索引 0 开始的规范。
我每次尝试运行 subsonic.exe/generate 时都会得到它
一切看起来都很简单!!!
这是我的 Web.Config
<!-- connectionString="Persist Security Info=False;database=config;server=localhost;user id=config;Password=config" -->
<connectionStrings>
<remove name="ConfigConnectString"/>
<add name="ConfigConnectString" connectionString="Persist Security Info=False;database=config;server=localhost;user id=userid;Password=password" providerName="MySql.Data.MySqlClient"
/>
</connectionStrings>
<SubSonicService defaultProvider="ConfigDatabase">
<providers>
<add type="SubSonic.MySqlDataProvider, SubSonic"
name="MySqlDataProvider"
generatedNamespace="Config"
connectionStringName="ConfigConnectString"
/>
</providers>
</SubSonicService>
我已经尝试了一些事情:
- 使用外部工具路径上的/config 指定 webconfig 的路径。
- 根据示例从 6.0 .NET MySQL 连接器降级到最新的 5.2 版本。
- 将 MySQL.Data 作为引用直接从 SubSonic 文件夹添加到其中的 DLL。
- 根据 http://www.connectionstrings.com/mysql#28 尝试各种格式的连接字符串
(其他连接字符串:“Server=localhost;Database=config;Uid=user;Pwd=password;”- 还有“blah”/“anything”会抛出同样的错误...)
不快乐!非常接近放弃 SubSonic。如果可以,请帮忙!
顺便说一句,我正在使用 Subsonic 2.2
最佳答案
我是个白痴:
<SubSonicService defaultProvider="ConfigDatabase">
应该是:
<SubSonicService defaultProvider="MySqlDataProvider">
呸!
关于.net - MySQL & .NET : System. ArgumentException:初始化字符串的格式不符合从索引 0 开始的规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/806435/