Question

I am using latest version of Fluent NHibernate automapping. Is there any convention or property I can set to stop creating the foreign key constraints across all the tables? I have nearly 200 classes, So I cannot go to each individual class and property name and set

 ForeignKeyConstraintNames("none", "none") 

How can we add ForeignKeyConstraintNames("none", "none") in Automapping? I don't want to hardcode the table name or column name. I would like to have the AutoMapping create all the mappings without foreign keys. Basicall don't create any foreign keys across the database. How can we do this? There is similar POST HERE but the answer was not clear to me.

Était-ce utile?

La solution

a simple convention

public class NoForeignKeys : IReferenceConvention, IHasManyConvention
{
    public void Apply(IManyToOneInstance instance)
    {
        instance.ForeignKey("none");
    }

    public void Apply(IOneToManyCollectionInstance instance)
    {
        instance.Key.ForeignKey("none");
    }
}

// use it
AutoMap.AssemblyOf().Conventions
    .FromAssembly() or .Add(typeof(NoForeignKeys))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top