1
votes

I am beginner to Fluent Nhibernate. i have created one sample application in asp.net mvc 3 with Fluent Nhibernate. here is the code that i am using for initialisation.

private static void initialisationFactory() { try {
_sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(@"Server=10.10.10.10;Database=Product_Demo;uid=sa;pwd=12345;Trusted_Connection=false;"))
.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; } }

Now is it necessory to add .Mapping..... lines for all tables? like below..

.Mappings(m => m.FluentMappings.AddFromAssemblyOf().ExportTo("d:\"))

And will it be increase memory of the project while running?

Thanks in advance.

1

1 Answers

0
votes

You only need to do it once. Point it to where your entities are:

.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Product>.ExportTo("d:\"))

where Product is a class in your project where all the rest of your classes are declared/included.