ASP.NET Boilerplate(ABP)是否支持.NET Core 2.0下的NHibernate?
Hey there! Great question—let me break this down for you clearly:
Yes, ASP.NET Boilerplate (ABP) does support NHibernate in .NET Core 2.0 environments
ABP provides dedicated support for NHibernate via theAbp.NHibernateNuGet package, which has a version specifically adapted for .NET Core 2.0. You can safely reference this package in your project to integrate NHibernate seamlessly.Configuration steps are straightforward
To set up NHibernate in your ABP module, you'll configure it in thePreInitializemethod of your module class. Here's a quick example of what that might look like:public override void PreInitialize() { Configuration.Modules.AbpNHibernate().FluentConfiguration .Database(MsSqlConfiguration.MsSql2012.ConnectionString(c => c.FromConnectionStringWithKey("Default"))) .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(YourProjectModule).Assembly)); }This lets you define your database provider, connection string, and mapping sources (like Fluent NHibernate mappings) directly within ABP's module system.
ABP's repository system works seamlessly with NHibernate
You don't have to build your own repository layer from scratch. ABP offers a pre-built NHibernate repository implementation—just inheritNhRepositoryBase<TEntity, TPrimaryKey>for custom repositories, or use the genericIRepository<TEntity, TPrimaryKey>interface directly. This integrates perfectly with ABP's unit of work and dependency injection systems.A quick note on versions
While .NET Core 2.0 is supported, make sure you pick an ABP version that explicitly targets .NET Core 2.0. Newer ABP versions might have moved on to support newer .NET Core releases, but you can find compatible versions on NuGet by filtering for .NET Core 2.0 compatibility.
内容的提问来源于stack exchange,提问作者Lau YW




