Error on BuildSessionFactory
I'm trying to build my session factory using Fluent NHibernate and keep getting the following error.
Unable to cast object of type 'MySql.Data.MySqlClient.MySqlConnection' to type 'System.Data.Common.DbConnection'.
I've googled the heck out of the error and have found several proposed solutions, none of which work. Including making sure I have MySql.Data.dll referenced and in the output folde. Here's the code I'm using, it crashes on the .BuildSessionFactory() call. Thanks for any assistance you can provide!
Assembly thisAssembly = Assembly.GetExecutingAssembly();
IPersistenceConfigurer pc =
MySQLConfiguration.Standard
.ConnectionString(config.ConnectionString)
.Driver("NHibernate.Driver.MySqlDataDriver")
.Provider("NHibernate.Connection.DriverConnectionProvider")
.Dialect("NHibernate.Dialect.MySQLDialect");
_sessionFactory = Fluently.Configure()
.Database(pc)
.Mappings(m => m.FluentMappings.AddFromAssembly(thisAssembly))
.BuildSessionFactory();
2 Posted by RLangton on 12 Jul, 2010 11:22 PM
Fixed.
Was using an old version of MySql.Data.dll (1.0.10)
Newest version is 6.1.4.0