views:

89

answers:

3

Hi

I'm using fnh and castle nhib facility.

I followed the advice from mike hadlow here: http://mikehadlow.blogspot.com/2009/01/integrating-fluent-nhibernate-and.html

here is my FluentNHibernateConfigurationBuilder:

public Configuration GetConfiguration(IConfiguration facilityConfiguration)
    {
        var defaultConfigurationBuilder = new DefaultConfigurationBuilder();
        var configuration = defaultConfigurationBuilder.GetConfiguration(facilityConfiguration);

        configuration.AddMappingsFromAssembly(typeof(User).Assembly);

        return configuration;

    }

i know the facility is picking it up as i can break inside that method and it steps through.

however, when it's done, non of the mappings are created and i get the following error when i try to save an entity:

No persister for: IsItGd.Model.Entities.User

here is my user class:

//simple model of web user
public class User
{

    public virtual int Id { get; set; }

    public virtual string FullName { get; set; }

}

and here is the mapping:

 public class UserMap : ClassMap<User>
{
    public UserMap() {

        Id(x=>x.Id);
        Map(x=>x.FullName);
    }
}

i really can't see what the problem is. the strange thing is - is that if i use automapping it picks everything up - but i don't want to use automapping as i can't do certain things in that scenario.

any clues?

w://

A: 

Are your mapping files located in the same assembly as you domain classes? Otherwise you might want to use UserMap instead of User when specifying the assembly to look in:

configuration.AddMappingsFromAssembly(typeof(UserMap).Assembly);
Erik Öjebo
A: 

this has been fixed - it was a bug in fnh :(

cvista
A: 

I am encountering the same problem. I have Domain Entities under namespace SampleProj.Entities, my Mappings under namespace SampleProj.NHibernate and I have all my unit tests under SampleProj.UnitTests.

I am getting, "No Persister for ..entity" error when I am trying to implement

session.Get<Entity>(int id)

I am adding my assemblies in the file NHibernateHelper.cs under SampleProj.UnitTests as

 configuration.AddAssembly(typeof(RecipientTestMap).Assembly);

During debug, when I looked at the properties of configuration (just after it passed the above line), it is showing ClassMappings count as "0". I think it is somehow not grabbing this assembly.

But My Mapping test passes.

I am just clueless as to what I am missing. I really appreciate any help.

Thanks, Aparna

Aparna