nhibernate / NHibernate.MySqlConnector

GNU Lesser General Public License v2.1
8 stars 10 forks source link

SchemaUpdate doesn't work #8

Open rachelbahar opened 3 years ago

rachelbahar commented 3 years ago

FluentNHibernate 3.1.9 NH 5.3.9 MySqlConnector 1.3.11 NHibernate.Driver.MySqlConnector 2.0.0

Executing the following code doesn't work:

  var config = Fluently.Configure()
                .Database(MySQLConfiguration.Standard
                    .ConnectionString("User Id=aaa;Password=bbb;Host=localhost;Port=3306;Database=test;Default Command Timeout=120;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;Character Set=utf8;")
                    .Dialect<MySQLDialect>()
                    .Driver<MySqlConnectorDriver>()
                    .ShowSql()
                    .FormatSql())
                .Mappings(x => x.FluentMappings.AddFromAssemblyOf<User>())
                .BuildConfiguration();

            //var updater = new SchemaExport(config);
            //updater.Create(true, true);

            var updater = new SchemaUpdate(config);
            updater.Execute(true, true);

Note: create does work (but update doesn't)

TestNHMySqlSchemaUpdate.zip

hazzik commented 2 years ago

Hi @rachelbahar could you please describe what did yo mean by 'does not work'? Does it throw exception? Do nothing? Or what?

rachelbahar commented 2 years ago

Hi, "Doesn't work" means that the code execution of this line updater.Execute(true, true); takes long and the schema is not updated

You can check with the attached project -

  1. Creating the users table from the code (you can do it by commenting lines 34-35 and uncommenting lines 31-32) - works fine.
  2. Updating the users table (add a property to the User domain and map) - Takes long time and the new column is not added to the table.
pigsi commented 1 year ago

Hi , I found the problem!! It is at MySqlConnector side. NHibernate sends requests for metadata for specific SCHEMA and utilizes restrictionsValues which are ignored from MySqlConnector . image [Part of MySqlConnector Source code]

I've made the changes and a private build to work with MySqlConnector version 2.1.2 for .net6.0 but NHibernate.MySqlConnector package has dependencies and overwrites my fixed version of MySqlConnector with the original. Is there a way to overcome this issue without post build actions ? or I must fork this project and add PrivateAssets=All to PackageReference?