Hi, I'm using Fluent in a project utilizing the table per subclass
strategy with autoMapping. Everything is going smoothly except that
the ForeignKey Column in the database does not match the default
convention of BaseClassName + "Id". I have seen autoMapping
conventions where we can change the PrimaryKey Column name, but not
the ForeignKey Column name. In the example below my subclass "User"'s
associated table has an identity column name that is not
"BusinessEntityId". I know that I can set the column name with
standard fluent mapping, but I would really like to see this work with
autoMapping.
Thank you James for the update a few hours back on autoMapping Enums.
-Andrew

Session Factory:

            _factory = Fluently.Configure()
                .Database(MsSqlConfiguration
                              .MsSql2005
                              .ConnectionString(
                              c =>
                              c.Is("DB CONNECT STRING"))
                              .ShowSql())
                .Mappings(m =>
                        m.AutoMappings
                            .Add
(AutoPersistenceModel.MapEntitiesFromAssemblyOf<BusinessEntity>()
                                     .Where(type =>
type.Namespace.EndsWith("Core"))
                                     .WithConvention(convention =>
                                                     {
 
convention.GetTableName =
                                                             type =>
"Core." + Pluralizer.ToPlural(type.Name);
                                                     }))
                            .ExportTo(@"F:\Test\Fluent\"))
                .BuildSessionFactory();


My NHibernate config xml output:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
lazy="true" assembly="FluentUnity3" namespace="FluentUnity3.Core">
  <class name="BusinessEntity" table="Core.BusinessEntities"
xmlns="urn:nhibernate-mapping-2.2">
    <id name="Id" column="Id" type="Int32">
      <generator class="identity" />
    </id>
    <property name="CreatedOn">
      <column name="CreatedOn" />
    </property>
    <property name="ModifiedBy">
      <column name="ModifiedBy" />
    </property>
    <property name="CreatedBy">
      <column name="CreatedBy" />
    </property>
    <property name="ModifiedOn">
      <column name="ModifiedOn" />
    </property>
    <joined-subclass name="FluentUnity3.Core.User, FluentUnity3,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
table="Core.Users">
      <key column="BusinessEntityId" />
      <property name="LastName" length="100" type="String">
        <column name="LastName" />
      </property>
      <property name="Gender" not-null="false"
type="FluentNHibernate.Mapping.GenericEnumMapper`1
[[FluentUnity3.Core.User+Sex, FluentUnity3, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null]], FluentNHibernate,
Version=0.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880">
        <column name="Gender" sql-type="string" />
      </property>
      <property name="FirstName" length="100" type="String">
        <column name="FirstName" />
      </property>
      <property name="MembershipProviderId">
        <column name="MembershipProviderId" />
      </property>
      <property name="DisplayName" length="100" type="String">
        <column name="DisplayName" />
      </property>
    </joined-subclass>
  </class>
</hibernate-mapping>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to