Thursday, 22 August 2013

Custom Conventions for Navigation Properties in EF6 RC1

Custom Conventions for Navigation Properties in EF6 RC1

In EF6 beta I have a custom convention that change the DeleteAction based
on a custom attribute. In the new EF6 RC1 that aproach is no longer valid
and I could not found any way to do this using the new class.
public class MyConventions : IConfigurationConvention<PropertyInfo,
NavigationPropertyConfiguration> {
public void Apply(PropertyInfo propertyInfo,
Func<NavigationPropertyConfiguration> configuration)
{
var c = configuration();
if (c.DeleteAction == null)
{
var prop =
propertyInfo.GetCustomAttribute<DeletarEmCascataAttribute>();
if (prop != null)
configuration().DeleteAction = OperationAction.Cascade;
}
} }

No comments:

Post a Comment