Error on BuildSessionFactory

RLangton's Avatar

RLangton

12 Jul, 2010 09:53 PM via web

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();
  1. 2 Posted by RLangton on 12 Jul, 2010 11:22 PM

    RLangton's Avatar

    Fixed.
    Was using an old version of MySql.Data.dll (1.0.10)
    Newest version is 6.1.4.0

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What month comes before July?