NHibernate AutoMapping configurations with custom attributes and json column support.
It uses NHibernate's AutoMapping conventions for reading custom attributes over classes and properties and does database mapping, without the need of xml and and fluent mapping.
dotnet add package Sl.DataAccess.NH
//The assembly that contains table class definitions
Assembly myAssembly = Assembly.GetAssembly(typeof(MyTable));
IPersistenceConfigurer dbConfig = MsSqlConfiguration.MsSql2012.ConnectionString("foo");
IAuditService myAuditService = new MyAuditService();
SlSession.ConfigureSessionFactory(myAssembly, dbConfig,
SessionContextType.ThreadStatic,
myAuditService,
DBSchemaUpdateMode.Update_Tables);
Generates primary key. It can generate a composite primary key if it was put over two properties.
It can also be used over foreign key fields.
Makes any field, including foreign key fields, NotNull.
Can be used over string fields to indicate Maximum Length.
Creates time typed columns in supported databases. (Time without date)
Creates date typed columns in supported databases (Date without time)
Crates an index over specified column or columns.
Creates a unique index over specified column or columns.
Sets the string columns type to varchar instead of nvarchar supported databases.
Sets the column name in database.
Ignores the property during mapping.
Sets the table Name in database when put on a class.
Can be put on a property of complex type. It generates an nvarchar(max) column in database and parses the value into json.
It generates a jsonb typed column in Postgres.
Audit can be done using dependency injection by extending IAuditService.