Reputation: 4196
Nowaday I am using NHibernate + ASP.NET MVC 3 in my project. Always I add a new class model I need to set the SchemaExport like this:
Fluently
.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString).ShowSql())
.Mappings(m => m.FluentMappings
.AddFromAssembly(typeof(Usuario).Assembly)
.AddFromAssembly(typeof(Empresa).Assembly)
.AddFromAssembly(typeof(TipoUsuario).Assembly))
.ExposeConfiguration(config =>
{
var schemaExport = new SchemaExport(config);
schemaExport.Drop(true, true);
schemaExport.Create(true, true);
})
Is there any way to everytime the schemaExport export a new model insert a collection of default values in a couples of tables?
Upvotes: 1
Views: 702
Reputation: 5664
Whilst not strictly answering your question, I've found that using NHibernate to generate the schema quickly hits the types of problems you are currently facing. So, instead of using NHibernate I use Fluent Migrator instead. You can then create / modify your schema and add data into the schema in a very nice fluent based API without tying yourself to a specific flavour of SQL.
Upvotes: 1