문제

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.

도움이 되었습니까?

해결책

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))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top