我在資料庫中創建記錄時遇到問題。
我不知道那可能是什么。
當我重新啟動應用程式時會發生這種情況,最大的問題是應用程式沒有回傳錯誤。
我正在使用 AspnetCore 和 NHibernate。
我認為這將是這里的問題,但我正在發布專案鏈接。
public void ConfigureServices(IServiceCollection services)
{
//
var _sessionFactory = Fluently.Configure()
.Database(PostgreSQLConfiguration.Standard.ConnectionString(Configuration.GetConnectionString("DefaultConnection")))
.Mappings(x => x.FluentMappings.AddFromAssembly(GetType().Assembly))
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(false, false);
schemaExport.Create(true, true);
})
.BuildSessionFactory();
services.AddScoped(f =>
{
return _sessionFactory.OpenSession();
});
services.AddControllersWithViews();
}
GitHub 上的專案 - https://github.com/MatheusHenrique421/Hibernate_/tree/master
uj5u.com熱心網友回復:
以下代碼行將洗掉并創建資料庫:
schemaExport.Create(true, true);
每次啟動應用程式時,該行代碼都會作為應用程式引導的一部分執行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/340360.html
