PostSharp and EF Code first

dom's Avatar


17 Nov, 2017 02:53 PM


I had an issue with trying to create what on the face of it should have been a simple one to many relationship in code first with Entity Framework. To cut a long story short I ended up resorting to Stackoverflow

where someone spotted that I might well be using PostSharp. This led to a second quest that Gael answered a while ago

This all makes perfect sense to me now, but leads to one question where should I be adding the MulticastAttributeUsageAttribute.AttributeTargets . I hope by looking at the question I posed you will very quickly get a gist of how things are set up, but in essence my base VtlEntityBase class (in its own assembly) implements the PS NotifyPropertyChanged attribute. Is that where I should be looking or just in those areas where I want to specifically have relationships implemented by EF code first.

Many thanks


  1. 1 Posted by dom on 17 Nov, 2017 03:07 PM

    dom's Avatar

    Just to add to this. This is the first instance where I have seen this happen, in other words it appears to be directly related to the creation of one to many relationships in code first (I have created other many to many relationships that haven't exhibited this behaviour. Perhaps therefore I just need to remove the implementation of NotifyPropertyChanged from the Virtual ProductCategory references in the two affected classes.


  2. 2 Posted by dom on 17 Nov, 2017 03:14 PM

    dom's Avatar

    Problem solved

    Added [IgnoreAutoChangeNotification] to the two affected properties, please accept my apologies for troubling you.


  3. Support Staff 3 Posted by PostSharp Techn... on 21 Nov, 2017 03:19 PM

    PostSharp Technologies's Avatar


    no problem. We are happy that you have found a solution for the problem.

    Best regards,

  4. PostSharp Technologies closed this discussion on 21 Nov, 2017 03:19 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac