0
我想在創建數據庫之後將固定數據插入表(如城市,城鎮,工作,部門等)。我想我需要一個NHibernate的助手類來做到這一點,但如何?如何在NHibernate數據庫創建後將固定數據插入數據庫?
public static ISessionFactory CreateSessionFactory()
{
IPersistenceConfigurer dbConfigurer = MySQLConfiguration.Standard.ConnectionString(c => c.FromConnectionStringWithKey("test_nh"));
var fConfig = Fluently.Configure()
.Database(dbConfigurer)
.Mappings(m => m.FluentMappings
.AddFromAssemblyOf<Adres>()
)
.ExposeConfiguration(cfg =>
{
SchemaExport config = new SchemaExport(cfg).Create(true, true);
// I think code will be here
// There is file which contains sql script to insert data
})
.BuildSessionFactory();
return fConfig;
}