I have a project structure like this:
1. NHibernate Base classes to open session, data access function and CRUD methods. (Dll)
2. An exectue program (windows forms) which has domain classes and mappers in a separate namespace. (EXE)
3. NUnit test cases (Dll)
I have used the following code to create configuration:
public Configuration BuildConfig()
{
var configuration = new Configuration();
return Fluently.Configure(configuration)
.Mappings(cfg => {
cfg.FluentMappings.AddFromAssembly(Assembly.GetEntryAssembly());
}).BuildConfiguration();
}
When I tried to create configuration from 2n program (Windows forms application) the configuration has successfully done.
Now I've referenced both the above assemblies in NUnit Test assembly and I have copied the same configuration settings (app.config) as the windows form. Fluent is not able to build the session factory and I'm getting the following exception:
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
Database was not configured through Database method.
Please help me to resolve this issue.