【问题标题】:FLuentNhibernate + AutomappingFLuentNhibernate + 自动映射
【发布时间】:2012-03-14 06:25:11
【问题描述】:

谁能帮助我使用 FluentNhibernate 和自动映射?

查看PotentialReasons 集合,并查看InnerException 以获取更多详细信息。 ----> FluentNHibernate.Cfg.FluentConfigurationException : 创建 SessionFactory 时使用了无效或不完整的配置。检查 PotentialReasons 集合和 InnerException 了解更多详细信息。 ----> FluentNHibernate.Visitors.ValidationException : 实体 'NHibernateSessionManager' 没有映射的 Id。使用 Id 方法映射您的身份属性。例如:Id(x => x.Id)。

我正在尝试从我的课程中自动映射,这是代码:

FluentConfiguration config = Fluently.Configure()
         .Database(MySQLConfiguration.Standard
         .ConnectionString(c => c
             .Server("127.0.0.1")
             .Database("db")
             .Username("root")
          .Password("pass")));

        _sessionFactory = config.Mappings(
                   m => m.AutoMappings.Add(AutoMap.AssemblyOf<Product>())
                   .ExportTo(@"c:\hbm\"))

                   .BuildSessionFactory();

【问题讨论】:

    标签: fluent-nhibernate automapping fluent-nhibernate-mapping


    【解决方案1】:

    AutoMap.AssemblyOf&lt;Product&gt;() 尝试映射程序集中的所有类。

    设置像AutoMap.AssemblyOf&lt;Product&gt;(t =&gt; t.Namespace.StartsWith(typeof(Product).Namespace))这样的文件管理器

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      • 2015-09-09
      • 2012-01-21
      相关资源
      最近更新 更多