2

I am using NHibernate and Fluent NHibernate for the first time. I had to physically create the database and write SQL scripts for the first 2 tables. Now, i am wondering if this technology (NHibernate), like Entity Framework (Code First) when you have enabled migrations has a similar too to create and update tables?

This is what i mean by Ef Code First Automatic Migrations

Komengem
  • 3,662
  • 7
  • 33
  • 57

1 Answers1

1

nHibernate does support schema changes using SchemaUpdate

See: Is NHibernate SchemaUpdate safe in production code?

You can also generate a create script to execute against your database using nHibernate SchemaExport.

SchemaUpdate is not recommended for production use because of the security privileges that have to be granted in order for this to work. Personally I think you should look at a code based migrations tool which are designed to handle initial database creates plus full revision control, I use Migrator.NET - Database migration in C#

Community
  • 1
  • 1
connectedsoftware
  • 6,987
  • 3
  • 28
  • 43
  • I like the idea of Database Migration. Loved it when i worked with Ruby on Rails. However, Migrator.Net doesn't get updated as much so i will try to replicate the idea with Fluent Migrator. http://nuget.org/packages/FluentMigrator/1.1.1.0 – Komengem Jun 27 '13 at 17:55
  • @KomengeMwandila absolutely any migration tool is a useful companion, I particularly like being able to roll the database forward (up) and backward (down) to version match the code-base. – connectedsoftware Jun 27 '13 at 19:26
  • I fail to update my schema, can you look at my question here please : https://stackoverflow.com/questions/63368078/nhibernate-not-detecting-schema-changes-how-to-update – AymenDaoudi Aug 12 '20 at 03:50