2

I use NHibernate 3.0 with fluent configuration. I automap my persistent model like this:

AutoMap
    .AssemblyOf<BaseEntity>()
    .Where(type => type.Namespace != null && type.Namespace.Contains("PersistendModel"))

This works fine, but I don't want to use the default identifierGenerators. My objects have initialized GUID Id's, but as it stands now they are overwritten by NHibernate.

What do i need to add (Convention, Override, SomeThingElse?), so this will not happen.

mathieu
  • 30,974
  • 4
  • 64
  • 90
k.c.
  • 1,755
  • 1
  • 29
  • 53

1 Answers1

4

I added the following convention:

public class IdConvention : IIdConvention
{

    public void Apply(IIdentityInstance instance)
    {
        instance.GeneratedBy.Assigned();
    }

}

this does the trick for all my persisted classes in one go.

k.c.
  • 1,755
  • 1
  • 29
  • 53