需要帮助在 Fluent NHibernate 中配置 SQL Server CE 连接字符串
我试图使用以下代码返回会话工厂:
return Fluently.Configure()
.Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(path))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Project>())
.BuildSessionFactory();
Path 是 .sdf 文件的完整路径。
并得到这个例外:
System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
at System.Data.SqlServerCe.ConStringUtil.GetKeyValuePair(Char[] connectionString, Int32 currentPosition, String& key, Char[] valuebuf, Int32& vallength, Boolean& isempty)
我做错了什么?
I'm trying to return a session factory using this code:
return Fluently.Configure()
.Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(path))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Project>())
.BuildSessionFactory();
Path is the full path to an .sdf file.
And get this exception:
System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
at System.Data.SqlServerCe.ConStringUtil.GetKeyValuePair(Char[] connectionString, Int32 currentPosition, String& key, Char[] valuebuf, Int32& vallength, Boolean& isempty)
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://connectionstrings.com/sql-server-2005-ce
我从来没有以前使用过 sdf,但我的猜测是尝试这样的事情。您必须使用有效的连接字符串,并且仅提供路径不是有效的连接字符串。
传递它而不是路径。理想情况下,这来自配置文件中的连接字符串部分。
http://connectionstrings.com/sql-server-2005-ce
I've never used an sdf before, but my guess is to try something like this. You have to use a valid connection string, and simply providing the path is not a valid connection string.
Pass that in instead of path. Ideally this would come from the connection strings section in your config file.
这是解决方案:
来源在这里:
http://marekblotny.blogspot.com/2009/02/ Fluentconfiguration -new-api-to.html
Here is the solution:
Source here:
http://marekblotny.blogspot.com/2009/02/fluentconfiguration-new-api-to.html