NHibernate类映射=0

NHibernate类映射=0,nhibernate,fluent-nhibernate,Nhibernate,Fluent Nhibernate,我正在尝试使用NHibernate/FluentNHibernate在我的数据库中创建一个表。我似乎已经在很大程度上解决了这个问题,但是当我运行测试时,表并没有被创建。我在配置对象中看到类映射是一个巨大的零,即使我有用户FluentNHibernate从程序集配置它们。我有些理解这一点,但我错过了一些地方的联系。。。这是代码片段,也许有人能看到我想要的 这是我的dataconfig类 public static FluentConfiguration GetFluentConfiguration

我正在尝试使用NHibernate/FluentNHibernate在我的数据库中创建一个表。我似乎已经在很大程度上解决了这个问题,但是当我运行测试时,表并没有被创建。我在配置对象中看到类映射是一个巨大的零,即使我有用户FluentNHibernate从程序集配置它们。我有些理解这一点,但我错过了一些地方的联系。。。这是代码片段,也许有人能看到我想要的

这是我的dataconfig类

public static FluentConfiguration GetFluentConfiguration()
    {
        string hibernateCfgFile = @"C:\Users\kenn\Documents\Visual Studio 2008\Projects\NHibernateTestTwo\Infrastructure\hibernate.cfg.xml";
        return Fluently.Configure(new Configuration().Configure(@hibernateCfgFile))
            .Mappings(cfg => cfg.FluentMappings.AddFromAssembly(typeof(AddressMap).Assembly));
    }
这是测试课

[Test, Explicit]
    public void SetupDatabase()
    {
        FluentConfiguration conf = DataConfig.GetFluentConfiguration();
        conf.ExposeConfiguration(BuildSchema).BuildSessionFactory();
    }

    private static void BuildSchema(Configuration conf)
    {
        new SchemaExport(conf).SetOutputFile("drop.sql").Drop(false, true);
        new SchemaExport(conf).SetOutputFile("create.sql").Create(false, true);
    }
下面是映射

 public AddressMap()
    {

        Table("Address");
        DynamicUpdate();
        Id(a => a.Id).GeneratedBy.GuidComb();
        Map(a => a.AddressOne).Not.Nullable().Length(100);
        Map(a => a.AddressTwo).Length(100);
        Map(a => a.City).Not.Nullable().Length(100);
        Map(a => a.state).Not.Nullable().Length(100);
        Map(a => a.zip).Not.Nullable().Length(50);
        Map(a => a.Primary).Not.Nullable();

    }
hibernate.cfg.xml文件

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
    <property name="connection.driver_class">
        NHibernate.Driver.SqlClientDriver
    </property>
    <property name="connection.connection_string">
        Data Source=MYPC;Initial Catalog=NHibernateSample;Integrated Security=True;
    </property>
    <property name="show_sql">true</property>
    <property name="dialect">
        NHibernate.Dialect.MsSql2005Dialect
    </property>
    <property name="adonet.batch_size">100</property>
    <!--<property name="proxyfactory.factory_class">
        NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
        NHibernate.ByteCode.LinFu
    </property>-->
    <property name="proxyfactory.factory_class">
        NHibernate.ByteCode.Castle.ProxyFactoryFactory, 
        NHibernate.ByteCode.Castle
    </property>
</session-factory>

NHibernate.Driver.SqlClientDriver
数据源=MYPC;初始目录=NHibernateSample;综合安全=真实;
真的
NHibernate.dialogue.mssql2005dialogue
100
NHibernate.ByteCode.Castle.proxyFactory,
NHibernate.ByteCode.Castle

我只是不知道那里少了什么。。。它显然是在与数据库对话,因为如果我将数据库的名称更改为不存在的名称,它会抛出一个异常,我被卡住了-我已经在这个问题上进行了一次又一次的讨论,只是还没有弄清楚,所以任何帮助都将不胜感激


谢谢

见我的评论。。。别忘了将地图类公开,否则FluentNHibernate将看不到它们。

Oh turd。。。我忘了公开AddressMap类。好吧,如果其他人偶然发现了这一点,希望它会有所帮助。:)