views:

98

answers:

2

I have multiple databases in my SharpArchitecture project and followed the guide outlined here:

http://wiki.sharparchitecture.net/FAQ.ashx

Everything works fine, except for my entities with assigned ids. I get a "database already configured" when trying to startup the application. Through some digging I get:

"Identity type must be integral (int, long, uint, ulong)"

public void Apply(FluentNHibernate.Conventions.Instances.IIdentityInstance instance)
        {
            instance.Column("Id");
            instance.UnsavedValue("0");
            instance.GeneratedBy.HiLo("1000");
        }

This is thrown during the instance.GeneratedBy.HiLo("1000"); This is odd as my mapping is to an assigned id, and a string. It seems to be ignoring my assigned id map:

[SessionFactory(DataGlobals.SecondDbFactoryKey)]
public class SecondDbEntityMap: IAutoMappingOverride<SecondDbEntity>
{
    public void Override(AutoMapping<SecondDbEntity> mapping) {
        mapping.Id(x => x.AssignedIdProperty).GeneratedBy.Assigned();
    }
}

That mapping should work, right? I have a couple of assigned id entities in my first database and they're mapped in the same fashion (sans session factory attribute) and work fine. I can't seem to figure this out.

A: 

I think this is because the HiLo generator can only work with integral types - so if your assigned ID is a string type, you'll need some other method for generating the identity.

Jon
A: 

HiLo is a generator strategy that must assign Id`s, if you are assigning them yourself you want to go with the Assigned strategy instead.

Sharp Arch, comes with a default set of fluentNh automappings, my guess is you need to check the bootstrapper code where it loads the automappings and either adjust them or override them there. Let me know if you still have trouble, I`d be happy to take a look at your code.

Chris Nicola