Reputation: 198
After following the steps outline in this Fluent NHibernate tutorial I am stuck on the issue described below.
When I build and run the project I encounter the following error when attempting to build the session factory: "An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail".
The InnerException contains the following error message: "...\bin\Debug\FluentNHibernate.dll] The signature is incorrect" and the PotentialReasons collection has a lenght of 0. (nothing was added).
Here is the method:
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c =>
c.Server("CHRIS-PC\\SQLEXPRESS")
.Database("TestDB")
.Username("test")
.Password("test")))
.Mappings(m =>
m.AutoMappings.Add(model))
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
I am using what I believe to be the latest version of the FluentNhibernate.dll (version 1.2). I cannot seem to find anyone having a similar issue on the 'net.
Upvotes: 1
Views: 676
Reputation: 1785
Try this
return Fluently.Configure().Database(MsSqlConfiguration.MsSql2008
.ConnectionString(@"Data Source=CHRIS-PC\\SQLEXPRESS;Initial Catalog=TestDB;User ID=test"))
.Mappings(m => m.AutoMappings.Add(model))
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
or use this let mymodel be a sample model
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(ConfigurationManager.ConnectionStrings["CHRIS-PC\\SQLEXPRESS"].ConnectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<mymodel>().Add<UsersMap>())
.ExposeConfiguration(cfg =>
{
new SchemaExport(cfg).Execute(false, true, false);
// new SchemaUpdate(cfg).Execute(true, true);
}).BuildSessionFactory();
Upvotes: 1