Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaUpdate doesn't work #8

Open
rachelbahar opened this issue Sep 2, 2021 · 3 comments
Open

SchemaUpdate doesn't work #8

rachelbahar opened this issue Sep 2, 2021 · 3 comments

Comments

@rachelbahar
Copy link

rachelbahar commented Sep 2, 2021

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
Copy link
Member

hazzik commented Oct 17, 2022

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

@rachelbahar
Copy link
Author

rachelbahar commented Oct 17, 2022

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
Copy link

pigsi commented Jan 13, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants