我正在使用流利的NHibernate。我想通过使用映射来创建数据库。我的代码是
Shared Function GetConfig() As FluentConfiguration
Return Fluently.Configure().Database(MySQLConfiguration.Standard.ConnectionString(Function(c) c.Server("localhost").Database("im").Username("root").Password("pass"))).Mappings(Function(m) m.FluentMappings.AddFromAssemblyOf(Of UserMap())())
End Function
GetConfig().ExposeConfiguration(Function(c) New SchemaExport(c).Execute(script, export__1, justDrop)).BuildConfiguration()
但是新的SchmaExport(c)无法编译。错误表达式不会产生值。我该怎么做才能解决这个问题。这个函数会为我创建数据库吗?或者我做错了?感谢
答案 0 :(得分:1)
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(_connectionString))
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.BuildSessionFactory();
答案 1 :(得分:1)
试试这个
GetConfig().ExposeConfiguration(Sub(x As NHibernate.Cfg.Configuration) Dim ex As SchemaExport = New SchemaExport(x)
ex.Execute(script, export__1, justDrop) End Sub).BuildConfiguration()