Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-66

ShadowProperty of type ObjectId is unsupported

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: Public Preview 1
    • None

      If an Entity is defined without an Id or _id property, and a Shadow Property is defined as part of the OnModelCreating method

      modelBuilder.Entity<ModelType>().Property<ObjectId>("Id");

      System.NotSupportedException is thrown at runtime 

      System.NotSupportedException: 'Unsupported shadow property 'TempId' identified on entity type 'ModelType'.'

      It can be desirable to have the entity identifier implemented as a shadow property to enable models to be easily ported between SqlServer and MongoDB, for example.

      For MongoDB

      modelBuilder.Entity<ModelType>().Property<ObjectId>("Id"); 

      For SqlServer

      modelBuilder.Entity<ModelType>().Property<uint>("Id");

       

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            bill@greyskin.co.uk Bill Richards
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: