Free NHibernate Data Deleted After Schema Update

I am using Fluent NHibernate to work with my database.

When you run the following code, some of them work. One function updates the table structure, which also works, but my data is gone.

ISessionFactory result = Fluently.Configure()
    .Database(MySQLConfiguration.Standard.ConnectionString(connectionString))
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Page>())
    .ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true))
    .BuildSessionFactory();

Does anyone have any ideas how to solve this? Tables should be updated, but data should not be deleted.

In the wiki from the free NH I can not find more information about ExposeConfiguration.

+3
source share
1 answer

SchemaExport(cfg).Create(true, true))this is what he does. I did not use Fluent, but, based on one of my projects, I just looked, I think it should be something likeSchemaUpdate(cfg).Execute(true,true)

Edit: since this answer still helps people, here is a longer explanation.

- , . SchemaExport DDL . Create script, , script . Create Execute, , , " , ". .

SchemaUpdate - (), , ( , , , ). . - " ddl ", - " ".

+15

All Articles