Fluent NHibernate 无法使用 SQLCE 创建会话工厂

发布于 2024-10-04 17:10:40 字数 1616 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走过海棠暮 2024-10-11 17:10:40

好吧,想通了。

复制本地不适用于我正在使用的测试项目,因此,库没有被复制到测试项目的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文