How can I add an additional field to my EF POCO which does not exists in DB? RRS feed

  • Question

  • Hello,

          I am using EF 4.1. I have a situation where I have to add 2 fields which is not map to original table where this Entity is belongs to. Neither I want to save it to Database table. I just want the value for read only purpose. What options I have in EF 4.1 in order to achive this behavior.

         Any help would be appreciated.




    Nilkanth Desai


    Monday, August 15, 2011 2:36 AM


  • Hi Nilkanth,


    There is NotMapped Attribute in Data Annotation.


    Placed on a property or class to exclude it from the database 

        public string Name
            return String.Format("{0} {1}", Title, FirstName);

    Here is a sample.

    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.

    • Marked as answer by Nilkanth Monday, August 15, 2011 8:05 AM
    Monday, August 15, 2011 6:36 AM