Determining if a property is cascade deleted in templates
Posted: Mon 07 Jul 2014 15:15
I am adding some additional code generation to the method GenerateRelationProperty(), which is in the template for DbContext.
What I want to determine is whether the relation property is cascade deleted or not.
There is no Intellisense here (typing relationProperty. returns nothing), so I have been trying to figure this out by guessing.
I found relationProperty.Association, which is of type EntityAssociation (determined by adding a generated comment with the type name of .Association). Elsewhere in the template, in GenerateCascadeOnDeleteMapping(), which is passed an EntityAssociation, I see it use: association.DeleteCascaded
However, if I try relationProperty.Association.DeleteCascaded, the template gives an error that EntityDeveloper.Association does not contain that property.
So, how do I determine whether the association property is cascade deleted?
Also, a second question if I may. I am generating other custom code for each property based on Property extended properties. However, there are both EntityProperty and EntityRelationProperty classes. Is there a common base class I can pass to my custom <#+ method that can be used to .GetProperty("name") for either kind?
What I want to determine is whether the relation property is cascade deleted or not.
There is no Intellisense here (typing relationProperty. returns nothing), so I have been trying to figure this out by guessing.
I found relationProperty.Association, which is of type EntityAssociation (determined by adding a generated comment with the type name of .Association). Elsewhere in the template, in GenerateCascadeOnDeleteMapping(), which is passed an EntityAssociation, I see it use: association.DeleteCascaded
However, if I try relationProperty.Association.DeleteCascaded, the template gives an error that EntityDeveloper.Association does not contain that property.
So, how do I determine whether the association property is cascade deleted?
Also, a second question if I may. I am generating other custom code for each property based on Property extended properties. However, there are both EntityProperty and EntityRelationProperty classes. Is there a common base class I can pass to my custom <#+ method that can be used to .GetProperty("name") for either kind?