【发布时间】:2014-01-21 12:00:23
【问题描述】:
我想在创建数据库后将固定数据插入到表中(如城市、城镇、工作、部门等)。我想我需要一个 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;
}
【问题讨论】:
标签: mysql c#-4.0 nhibernate fluent-nhibernate