That looks correct to me. I guess the naming is not very revealing, but what they PrimaryKeyConvention actually does is sets the *column name* of the primary key, not what the property should be called. So you still need to use the FindIdentity method to tell the automapper what your identities are called, because by default it looks for properties named Id, not ID.
On Thu, Mar 19, 2009 at 7:47 PM, rob <r...@locked.nl> wrote: > > Hi All, > > I am new to FluentNHibernate and i tried to achieve a basic > inheritance object structure and add use automapping with an > IIdConvention that sets the primarty key columnname to "ID" by > default. > > I tried using the PrimaryKeyConvention class that was in the wiki, but > doing so didn't result in a correct mapping ( the mapping xml file did > not contain the id ). When i left out the .WithSetup() part, the > IIdConvention did work, but then my abstract base class was included > in the mapping, which was is not wat i wanted. I worked around the > issue as in the code below, is this an agreeable workaround or am I > missing something and should the PrimaryKeyConvetion work as i > expected. > > Fluently.Configure() > .Database(MsSqlConfiguration.MsSql2005 > .ConnectionString(c => > c.FromConnectionStringWithKey("local"))) > .Mappings(m => > m.AutoMappings.Add( > > AutoPersistenceModel.MapEntitiesFromAssemblyOf<DomainObject>() > .WithSetup(s => > { > s.IsBaseType = type => > type == typeof(DomainObject); > s.FindIdentity = id => > id.Name == "ID"; > }) > .Where(t => t.Namespace == > "PurpleBall.Domain")) > // neither one of the 2 lines > below resulted in a correct mapping xml. > //.ConventionDiscovery.Add > (PrimaryKey.Name.Is(x=>"ID"))) > > //.ConventionDiscovery.Add<PrimaryKeyConvention> > ()) > .ExportTo(@"C:\Temp\") > ) > .ExposeConfiguration(BuildSchema) > .BuildSessionFactory(); > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---