背景:
我知道如何在asp.net mvc中添加“ hibernate.cfg.xml”,而不是在asp.net mvc核心中添加。
下面的代码适用于asp.net mvc
var configuration = new Configuration();
var configurationPath = HttpContext.Current.Server.MapPath(@"~\Models\hibernate.cfg.xml");
configuration.Configure(configurationPath);
configuration.AddAssembly(Assembly.GetExecutingAssembly());
//ISessionFactory sessions = new Configuration().Configure().AddAssembly(Assembly.GetExecutingAssembly()).BuildSessionFactory();
ISessionFactory sessionFactory = configuration.BuildSessionFactory();
return sessionFactory.OpenSession();
但是,asp.net核心中不存在语法代码“ HttpContext.Current.Server.MapPath”,为了在ASP.NET核心中添加“ hibernate.cfg.xml”,应使用什么代码?
谢谢!