如何使用 MySQL 配置流畅的 nHibernate [英] How to configure fluent nHibernate with MySQL

查看:28
本文介绍了如何使用 MySQL 配置流畅的 nHibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 nHibernate 配置为使用 MySql 数据库.我找到了 mssql 和 sqlite 的示例,但没有找到 mysql 的示例.那么,我该如何更改它以便它使用 mysql:

I'm trying to configure nHibernate to use a MySql database. I found examples for mssql and sqlite but none for mysql. So, how do I change this so it uses mysql:

Fluently.Configure().Database(
        MsSqlConfiguration.MsSql2005.ConnectionString(
            c => c.FromConnectionStringWithKey("ConnectionString")
        )
    )
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>())
    .BuildSessionFactory())

推荐答案

MsSqlConfiguration.MsSql2005 更改为 MySqlConfiguration.Standard,这是我贡献的一件事项目.

Change MsSqlConfiguration.MsSql2005, to MySqlConfiguration.Standard, it was the one thing I contributed to the project.

示例:

Fluently.Configure().Database(
        MySqlConfiguration.Standard.ConnectionString(
            c => c.FromConnectionStringWithKey("ConnectionString")
        )
    )
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>())
    .BuildSessionFactory())

这篇关于如何使用 MySQL 配置流畅的 nHibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆