views:

261

answers:

1

My Entity Class: public class Building { /// /// internal Id /// public virtual long Id { get; set; } .............. }

My Mapping:

var model = AutoMap.AssemblyOf() .Setup(s => s.FindIdentity = p => p.Name == "Id") .Where(t => t.Namespace == "SpikeAutoMappings");

var database = Fluently.Configure() .Database(DatabaseConfigurer) .Mappings(m=>m.AutoMappings.Add(model));

Need somebody to see what is wrong coz I keep having this error when run unit test: Initialization method TestProject1.MappingTestBase.TestInitialize threw exception. FluentNHibernate.Cfg.FluentConfigurationException: FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

---> FluentNHibernate.Visitors.ValidationException: The entity doesn't have an Id mapped. Use the Id method to map your identity property. For example: Id(x => x.Id)..

A: 

My experience with Automapping is that as long as your Entity class has the line:

    public virtual int Id { get; private set; }

the automapper will treat it as an ID with no further help from the programmer (i.e. no need for the FindIdenity code you are using in your AutoMap call).

The only difference I see in your ID declaration is that you use a type long instead of int. Don't know if this matters or not.

Tom Bushell
Thx Tom. Am using Oracle 10g and Id is long type. Tried your line and took out the setup FindIdentity... still got the same error....
Gini

related questions