When I am running tests on my Respiratory code the tables are dropped and created and fresh data is added for tests using
new SchemaExport(_configuration).Execute(false, true, false);
However it is enforcing referential integrity, in production this will be fine but in testing I require this to not be on.
Is there any way to disable them when creating the tables with the code above?
using FluentNHibernate it is just adding this convention for tests only
public class NoForeignKeys : IReferenceConvention, IHasManyConvention
{
public void Apply(IManyToOneInstance instance)
{
instance.ForeignKey("none");
}
public void Apply(IOneToManyCollectionInstance instance)
{
instance.Key.ForeignKey("none");
}
}
using plain NHibernate you would need to iterate through all mapped classes properties and change it there.
foreach (var prop in config.ClassMappings.SelectMany(c => c.PropertyClosureIterator).Where(p => p.IsEntityRelation || <is hasmany>))
{
// set foreignkey name to "none"
}