Hi i am stuck with one problem while dealing with fluent nhibernate.
My user entity is below
public class UserEntity
{
public virtual int Userid { get; set; }
public virtual CompanyEntity CompanyId { get; set; }
public virtual string Name { get; set; }
public virtual string Email { get; set; }
public virtual string Username { get; set; }
public virtual string Password { get; set;}
public virtual decimal MinLimit { get; set;}
public virtual decimal MaxLimit { get; set;}
public virtual DateTime Birthdate { get; set;}
public virtual RoleEntity Roleid { get; set; }
public virtual int CreatedBy { get; set;}
public virtual DateTime CreatedDate { get; set;}
public virtual bool Active { get; set;}
}
}
and mapping class is as below
public class UserMap : ClassMap
{
public UserMap()
{
Id(x => x.Userid);
References(x => x.CompanyId).Column("CompanyId").Cascade.All();
Map(x => x.Name);
Map(x => x.Email);
Map(x => x.Username);
Map(x => x.Password);
Map(x => x.MinLimit);
Map(x => x.MaxLimit);
Map(x => x.Birthdate);
References(x => x.Roleid).Column("Roleid").Cascade.All();
Map(x => x.CreatedBy);
Map(x => x.CreatedDate);
Map(x => x.Active);
Table("tblUsers");
}
}
Now when ever i am trying to execute my program it gives me error like.
Could not determine type for: ProductPO.Models.Entites.UserEntity, ProductPO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(CreatedBy)
My helper class is as below
private static ISessionFactory _sessionFactory;
private static ISessionFactory sessionFactory
{
get
{
if (_sessionFactory == null)
{
initialisationFactory();
}
return _sessionFactory;
}
}
private static void initialisationFactory()
{
try
{
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(@"Server=10.10.10.10;Database=Product;uid=sa;pwd=12345;Trusted_Connection=false;").ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<CompanyEntity>().ExportTo("d:\\"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ModuleEntity>().ExportTo("d:\\"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<RoleEntity>().ExportTo("d:\\"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<UserEntity>().ExportTo("d:\\"))
.ExposeConfiguration(cfg => new SchemaExport(cfg))
.BuildSessionFactory();
}
catch (Exception e)
{
throw;
}
}
public static ISession OpenSession()
{
return sessionFactory.OpenSession();
}
Thanks in advance