locked
Property of a poco ignored when mapping not exists. RRS feed

  • Question

  •  In my model if a POCO have a property of type which is not supported by EF (types for those mapping not provided), that property won’t be reflected in Database, and no error is thrown.

    Example: char, object.

     

    public class Dept

            {

                 public int Id { get; set; }

                 public char name { get; set; }  //“this won’t be reflected in database and no error would be thrown. Simply it ignores this property.”

                  public object pic { get; set; }  //same here

     

             }    

     

    Is this something like behavior by design? 

    Friday, August 19, 2011 5:52 AM

Answers

All replies

  • Hello,

    AFAIK, this was the limitation of Entity Framework. I made a test under EF4.1. It really didn't map char and object into Database. I think because entity data model doesn't show char type. This wasn't the primitive data type. I suggest you check it here. http://msdn.microsoft.com/en-us/library/bb399548.aspx

    Thanks,


    Larcolais Gong[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 Larcolais Gong Saturday, August 27, 2011 11:57 AM
    Monday, August 22, 2011 1:11 PM
  • Hi,

    Even char is a primitive type, I understand that we can only use EDMSimpleTypes, that are supported in the storage environment. Still I wonder how EF validation miss these things(unknown mappings or ignored mappings) when creating model at the backend, and doesn't report any error or warning to the user. Any hopes to get this fixed in future?

    thanks,

    Jagan 


    jagan
    Tuesday, August 23, 2011 6:20 AM
  • Hello,

    After I checked and consulted others, Code First always ignore properties which cannot be mappted. You can try to use EF metadata and compare the EF model to reflection information from your classes to check if any properties didn’t get mapped. Please check this property here. http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.metadataworkspace.aspx

    Thanks,


    Larcolais Gong[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 Larcolais Gong Saturday, August 27, 2011 11:57 AM
    Thursday, August 25, 2011 5:18 AM