Strange behavior in EF 4.1 Code First while annotating properties with NotMappedAttribute. RRS feed

  • Question

  • I have come across a behavior in EF CF that occurs as follows:

    I have a class called Templates. This is also a base class for other classes that are marked with the [NotMapped] attribute.

    Certain properties within this base class have also been marked as [NotMapped]. All works well up to this point.

    I now need to use this class for some business logic so I implement IDisposable on it. As a result, there is a property

    public bool Disposed {get; private set;}

    If I mark this particular property as [NotMapped], EF generates an error saying that the derived classes are not mapped whereas they have already been marked as [NotMapped]. If I remove the attribute from the Disposed property, everything goes back to normal.

    I could understand the issue if IDisposable required a property by that name and if EF was internally using it as well.

    Please advise.

    Tuesday, May 1, 2012 12:21 AM

All replies

  • Hi,


    We will do some more pending research  about your problem and come back as
    soon as possible, Thanks for understanding.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 2, 2012 2:54 PM
  • We have still not figure out a way around this and as a result, we have unnecessary fields like 'Disposed' in SQL Server. Is there any insight into this as yet?

    Raheel Khan

    Saturday, August 25, 2012 10:47 PM