How to write Fluent NHibernate convention for constraint names?

Viewed 44

I am using Fluent NHibernate 3.1.0 (with NHibernate 5.3.8) for my domain mappings. The project I am working on is targeting .NET 5. The database engine used is SQLite with the data provider System.Data.SQLite 1.0.113.7.

I am trying to find a way to apply convention for constraint names in my project. I really want to avoid names like FK_935624DA.

I cannot find the answer anywhere, but I am certain the infos is somewhere but I am overlooking! Of course I read the following (official) documentation on GitHub. https://github.com/nhibernate/fluent-nhibernate/wiki/Conventions

I have to say that however, by example I managed to define a custom foreign key convention that way:

internal class ForeignKeyNameConvention : ForeignKeyConvention
{
    protected override string GetKeyName(Member property, Type type) => type.Name + "ID";
}

Can you point me out in the right direction with a code sample or a link?

Thanks !

P.S. If I missed some infos, let me know, I am not really used to post on Stack Overflow.

0 Answers
Related