Fluent NHibernate 无法使用 SQLCE 创建会话工厂
我正在使用 Fluent NHibernate(任何 NHibernate 风格)尝试我的第一个项目。我一直无法超越创建 Session Factory 对象的阶段,因为我遇到了以下异常:
InnerException: NHibernate.HibernateException
Message=The IDbCommand and IDbConnection implementation in the assembly System.Data.SqlServerCe could not be found. Ensure that the assembly System.Data.SqlServerCe is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
Source=NHibernate
StackTrace:
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SqlServerCeDriver..ctor()
InnerException:
我正在使用最新的 FluentNHibernate 二进制文件。 VS 2010,在 Window 7 x64 上。我已将 System.Data.SqlServerCe 程序集设置为“复制本地”,将项目的目标平台更改为 x86。
流畅的配置是:
var config = Fluently.Configure()
.Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(cnxString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SyncContract>());
if (!File.Exists(dbPath))
{
var engine = new System.Data.SqlServerCe.SqlCeEngine(cnxString);
engine.CreateDatabase();
config.ExposeConfiguration(c => new SchemaExport(c).Create(false, true));
}
return config;
注意:engine.CreateDatabase() 工作正常。
有什么帮助/想法吗?
I'm trying out my very first project with Fluent NHibernate (any NHibernate flavor for that matter). I've been unable to get past the point of creating a Session Factory object as I'm running in to the following exception:
InnerException: NHibernate.HibernateException
Message=The IDbCommand and IDbConnection implementation in the assembly System.Data.SqlServerCe could not be found. Ensure that the assembly System.Data.SqlServerCe is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
Source=NHibernate
StackTrace:
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SqlServerCeDriver..ctor()
InnerException:
I'm using the latest FluentNHibernate binaries. VS 2010, on Window 7 x64. I've set the System.Data.SqlServerCe assembly to "Copy Local" changed the project's target platform to x86.
The fluent config is:
var config = Fluently.Configure()
.Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(cnxString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SyncContract>());
if (!File.Exists(dbPath))
{
var engine = new System.Data.SqlServerCe.SqlCeEngine(cnxString);
engine.CreateDatabase();
config.ExposeConfiguration(c => new SchemaExport(c).Create(false, true));
}
return config;
Note: engine.CreateDatabase() works fine.
Any help/ideas please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,想通了。
复制本地不适用于我正在使用的测试项目,因此,库没有被复制到测试项目的 bin 文件夹中。添加所有库作为对测试项目的引用,并在它们上设置本地副本以使其正常工作。
Ok, figured it out.
Copy Local didn't apply to the test project I was using and consequently, the libs didn't get copied to the bin folder of the test project. Added all the libraries as references to the test project and set copy local on them to get this to work.