2

How can I use Fluent NHibernate (with AutoMapping) to configure the default ID generation scheme to Guid.Comb? I can see that I could specify in each entity (or a base class) the following code:

Id(entity => entity.Id, "Id").GuidComb();

Which is fine. However this doesn't so much seem to be setting the default behavior as overriding it. I just want to know if I am missing a configuration trick.

Thanks for any help

James
  • 7,877
  • 7
  • 42
  • 57

1 Answers1

1

you should use conventions.
this way you can define default behaviour which would be applied to all your classes (or conditionally, if needed).

J. Ed
  • 6,692
  • 4
  • 39
  • 55
  • Could you give me an example of achieving this? I have tried creating a custom convention by implementing the implementing IClassConvention interface, but the following line of the "Apply" method give me the compiler error "Cannot resolve symbol ID": instance.Id(entity => entity.Id, "Id").GuidComb(); – James Sep 02 '11 at 13:34
  • 4
    Got it. Need to create a convention class that implements the IIdConvention interface. Then in the apply method just write: instance.GeneratedBy.GuidComb(); – James Sep 02 '11 at 13:55