The problem with using NHibernate SchemaUpdate with MySQL is that there is no error, but nothing happens!

I am having problems using SchemaUpdate with MySQL.

It seems that I implemented everything correctly, but when I run it it does not update anything. It does not generate any errors, and it pauses about as many times as you expected to take to check the DB schema, but it does not update anything, and when I try to get it before the script, this change just does not do anything - it seems to be able to: "do not detect any changes in the schema database, but I created a new object and a new mapping class - so I cannot understand why it does not pick it up.

       var config = Fluently.Configure()
               .Database(() => {
                   var dbConfig = MySQLConfiguration.Standard.ConnectionString(
                    c => c.Server(configuration.Get<string>("server", ""))
                        .Database(configuration.Get<string>("database",""))
                        .Password(configuration.Get<string>("password", ""))
                        .Username(configuration.Get<string>("user", ""))
                   );


               });

       config.Mappings(
           m => m.FluentMappings
                   .AddFromAssemblyOf<User>()
                   .AddFromAssemblyOf<UserMap>()
                   .Conventions.AddFromAssemblyOf<UserMap>()
                   .Conventions.AddFromAssemblyOf<PrimaryKeyIdConvention>()
           //      .PersistenceModel.Add(new CultureFilter())
               );


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

I don’t think that something is wrong with my config, because it works fine with ShemaExport - it’s just SchemaUpdate, where I look the problem.

!

+3
2

SchemaUpdate ? , AFAIK.

using (var tx = session.BeginTransaction())
{
    var tempFileName = Path.GetTempFileName();
    try
    {
        using (var str = new StreamWriter(tempFileName))
        {
            new SchemaExport(configuration).Execute(showBuildScript, true, false, session.Connection, str);
        }
    }
    finally
    {
        if (File.Exists(tempFileName))
        {
            File.Delete(tempFileName);
        }
    }

    tx.Commit();
}
+1

:

, MySQL . , MySQL / NHibernate , SchemaUpdate - . ,

Database=A

<class ... schema="B">

, SchemaUpdate , " " .

, , - SchemaUpdate ( USE schema;). afaik, NHibernate , ( , ). , XML ( XML) ...

0

Source: https://habr.com/ru/post/1796101/


All Articles