locked
The property 'TimeStamp' does not exist on type 'MyNamespace.Foo'. Make sure to only use property names that are defined by the type. RRS feed

  • Question

  • I am having extreme difficulty figuring this one out...

    I successfully created an OData service using Visual Studio 2012, WCF Data Services and Entity Framework 5. Testing my service worked beautifully and consuming the service worked flawlessly until I tried to create/update data using an MVC 4 running 5.1.0-rc.  While troubleshooting this I removed a property "TimeStamp" (also a binary of SQL type timestamp) from my service's EF model. This recompiled and tested fine. However, now, when I attempt to query the service...

    var context = new MyServiceNamespace.FooEntities(fooUri);
    this.ViewBag.ThisQueryIsBroken = context.Foos.Where(f => f.FooID == 3).SingleOrDefault();
    

    I get this nasty exception...

    The property 'TimeStamp' does not exist on type 'mynamespace.And.Type.Here'. Make sure to only use property names that are defined by the type.

       at Microsoft.Data.OData.ReaderValidationUtils.ValidateValuePropertyDefined(String propertyName, IEdmStructuredType owningStructuredType, ODataMessageReaderSettings messageReaderSettings, Boolean& ignoreProperty)
       at Microsoft.Data.OData.Atom.ODataAtomPropertyAndValueDeserializer.ReadPropertiesImplementation(IEdmStructuredType structuredType, List`1 properties, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, Boolean epmPresent)
       at Microsoft.Data.OData.Atom.ODataAtomEntryAndFeedDeserializer.ReadAtomContentElement(IODataAtomReaderEntryState entryState)
       at Microsoft.Data.OData.Atom.ODataAtomEntryAndFeedDeserializer.ReadAtomElementInEntry(IODataAtomReaderEntryState entryState)
       at Microsoft.Data.OData.Atom.ODataAtomEntryAndFeedDeserializer.ReadEntryContent(IODataAtomReaderEntryState entryState)
       at Microsoft.Data.OData.Atom.ODataAtomReader.ReadAtNavigationLinkEndImplementation()
       at Microsoft.Data.OData.ODataReaderCore.ReadImplementation()
       at Microsoft.Data.OData.ODataReaderCore.InterceptException[T](Func`1 action)
       at System.Data.Services.Client.Materialization.ODataReaderEntityMaterializer.ODataFeedOrEntryReader.TryRead()

    I have even recreated the old property in my model - this time with a name of "RowVersion". Same error. The bottom line is that I need to be able to make changes to my EF model like ignoring or renaming table fields without destroying my app. What gives?

    Please help!

    Tuesday, October 16, 2012 8:32 PM

Answers

  • Ok wow. This is going to be embarrassing...

    The line-before-the-line, where I was instantiating my context object, was using a host file alias in the URI that was pointing to a different server - a server that had the older version of the service. That older version, of course, was before my change to the property.

    SMH. My first real post on here, and I look like an ID10T. ugh.

    Thanks so much for at least trying to resolve my imaginary bug!

    • Marked as answer by DevDelimited Sunday, October 21, 2012 12:41 AM
    Sunday, October 21, 2012 12:40 AM

All replies

  • Hi,

    In order for the client to work correctly against a server, they need the same (or very similar) view of the model. On the server this is derived from EF (if you're using the EF provider). On the client this is derived from the generated classes. So if you change the model on the server please make sure that you regenerate the classes on the client. In VS this can be done by "Update Service Reference".

    The client can be a little out of sync from the server, but then you need to allow missing properties using this DataServiceContext.IgnoreMissingProperties. If this is on, the client will ignore properties which the server sends and the client doesn't know about (which seems to be the case of the error above).

    Thanks,


    Vitek Karas [MSFT]

    Tuesday, October 16, 2012 10:43 PM
    Moderator
  • Thank you, Vitek, for your swift reply.

    I set the IgnoreMissingProperties to true as you suggest, and, while that prevents the ODataException from being thrown, it does not resolve the real problem.  I have done all of the following...

    • Built and published my updated model to my service layer server.
    • Confirmed that the new field name is returned when queried directly (via Fiddler) for the same object
    • Executed the "Update Service Reference"
    • Verified that there is no mention of the old property - TimeStamp - in the generated Reference.cs
    • Verified that the new property - RowVersion - is present and identical to other like properties in the generated Reference.cs

    The error still occurs for any calls without the IgnoreMissingProperties property explicitly set to true.

    I can't in good conscious mark the IgnoreMissingProperties as the answer. I don't think that setting that flag on every instantiation of a context object is/was the designed/intended implementation.

    Thanks,

    -Tim


    Tuesday, October 16, 2012 11:47 PM
  • One other thing of note is that the new RowVersion property is correctly populated with a valid binary value when I query the OData service from Fiddler, but shows as null when I inspect the supposed same object in VS debug mode. ...curiouser and curiouser.
    Wednesday, October 17, 2012 12:17 AM
  • Could you share the class definition for the entity in question and the payload being read by the client (through Fiddler)?

    Thanks,


    Vitek Karas [MSFT]

    Wednesday, October 17, 2012 4:10 PM
    Moderator
  • Due to limits of this reply box, I am unable to paster the whole $metadata result but here is the relavant part...

    <?xml version="1.0" encoding="utf-8"?>
    <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
      <edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
        <Schema Namespace="MvcFrameworkModel" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
    
    
          <EntityType Name="Area">
            <Key>
              <PropertyRef Name="AreaID" />
            </Key>
            <Property Name="AreaID" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
            <Property Name="DisplayName" Type="Edm.String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="false" />
            <Property Name="RouteValue" Type="Edm.String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="false" />
            <Property Name="DisplayOrder" Type="Edm.Int32" Nullable="false" />
            <Property Name="Visible" Type="Edm.Boolean" Nullable="false" />
            <Property Name="Active" Type="Edm.Boolean" Nullable="false" />
            <Property Name="Created" Type="Edm.DateTime" Nullable="false" Precision="3" />
            <Property Name="CreatedBy" Type="Edm.String" Nullable="false" MaxLength="12" FixedLength="false" Unicode="false" />
            <Property Name="Updated" Type="Edm.DateTime" Precision="3" />
            <Property Name="UpdatedBy" Type="Edm.String" MaxLength="12" FixedLength="false" Unicode="false" />
            <Property Name="RowVersion" Type="Edm.Binary" Nullable="false" MaxLength="8" FixedLength="true" ConcurrencyMode="Fixed" p6:GetterAccess="Public" p6:SetterAccess="Public" p7:StoreGeneratedPattern="Computed" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:p6="http://schemas.microsoft.com/ado/2006/04/codegeneration" />
            <NavigationProperty Name="AreaRoles" Relationship="MvcFrameworkModel.FK_MVC_AreaRole_MVC_Area" ToRole="MVC_AreaRole" FromRole="MVC_Area" />
            <NavigationProperty Name="Controllers" Relationship="MvcFrameworkModel.FK_MVC_Controller_MVC_Area" ToRole="MVC_Controller" FromRole="MVC_Area" />
            <NavigationProperty Name="Reports" Relationship="MvcFrameworkModel.FK_MVC_Report_MVC_Area" ToRole="MVC_Report" FromRole="MVC_Area" />
          </EntityType>
    
    
        </Schema>
      </edmx:DataServices>
    </edmx:Edmx>

    ...and the response from http://acpbussvcdev/chapterportalservices/MvcFrameworkService.svc/Areas(11)

    <?xml version="1.0" encoding="utf-8"?>
    <entry xml:base="http://acpbussvcdev/chapterportalservices/MvcFrameworkService.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:etag="W/&quot;X'0000000000000F0B'&quot;">
      <id>http://acpbussvcdev/chapterportalservices/MvcFrameworkService.svc/Areas(11)</id>
      <category term="MvcFrameworkModel.Area" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link rel="edit" title="Area" href="Areas(11)" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AreaRoles" type="application/atom+xml;type=feed" title="AreaRoles" href="Areas(11)/AreaRoles" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Controllers" type="application/atom+xml;type=feed" title="Controllers" href="Areas(11)/Controllers" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Reports" type="application/atom+xml;type=feed" title="Reports" href="Areas(11)/Reports" />
      <title />
      <updated>2012-10-17T18:19:30Z</updated>
      <author>
        <name />
      </author>
      <content type="application/xml">
        <m:properties>
          <d:AreaID m:type="Edm.Int32">11</d:AreaID>
          <d:DisplayName>Admin</d:DisplayName>
          <d:RouteValue>admin</d:RouteValue>
          <d:DisplayOrder m:type="Edm.Int32">11</d:DisplayOrder>
          <d:Visible m:type="Edm.Boolean">true</d:Visible>
          <d:Active m:type="Edm.Boolean">true</d:Active>
          <d:Created m:type="Edm.DateTime">2012-09-24T10:50:07.02</d:Created>
          <d:CreatedBy>01390390</d:CreatedBy>
          <d:Updated m:type="Edm.DateTime" m:null="true" />
          <d:UpdatedBy m:null="true" />
          <d:RowVersion m:type="Edm.Binary">AAAAAAAADws=</d:RowVersion>
        </m:properties>
      </content>
    </entry>

    Class Diagram:

    EDM Diagram

    Wednesday, October 17, 2012 6:48 PM
  • Generated code from Reference.cs

        /// <summary>
        /// There are no comments for MvcFrameworkModel.Area in the schema.
        /// </summary>
        /// <KeyProperties>
        /// AreaID
        /// </KeyProperties>
        [global::System.Data.Services.Common.DataServiceKeyAttribute("AreaID")]
        public partial class Area
        {
            /// <summary>
            /// Create a new Area object.
            /// </summary>
            /// <param name="areaID">Initial value of AreaID.</param>
            /// <param name="displayName">Initial value of DisplayName.</param>
            /// <param name="routeValue">Initial value of RouteValue.</param>
            /// <param name="displayOrder">Initial value of DisplayOrder.</param>
            /// <param name="visible">Initial value of Visible.</param>
            /// <param name="active">Initial value of Active.</param>
            /// <param name="created">Initial value of Created.</param>
            /// <param name="createdBy">Initial value of CreatedBy.</param>
            /// <param name="rowVersion">Initial value of RowVersion.</param>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public static Area CreateArea(int areaID, string displayName, string routeValue, int displayOrder, bool visible, bool active, global::System.DateTime created, string createdBy, byte[] rowVersion)
            {
                Area area = new Area();
                area.AreaID = areaID;
                area.DisplayName = displayName;
                area.RouteValue = routeValue;
                area.DisplayOrder = displayOrder;
                area.Visible = visible;
                area.Active = active;
                area.Created = created;
                area.CreatedBy = createdBy;
                area.RowVersion = rowVersion;
                return area;
            }
            /// <summary>
            /// There are no comments for Property AreaID in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public int AreaID
            {
                get
                {
                    return this._AreaID;
                }
                set
                {
                    this.OnAreaIDChanging(value);
                    this._AreaID = value;
                    this.OnAreaIDChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private int _AreaID;
            partial void OnAreaIDChanging(int value);
            partial void OnAreaIDChanged();
            /// <summary>
            /// There are no comments for Property DisplayName in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string DisplayName
            {
                get
                {
                    return this._DisplayName;
                }
                set
                {
                    this.OnDisplayNameChanging(value);
                    this._DisplayName = value;
                    this.OnDisplayNameChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _DisplayName;
            partial void OnDisplayNameChanging(string value);
            partial void OnDisplayNameChanged();
            /// <summary>
            /// There are no comments for Property RouteValue in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string RouteValue
            {
                get
                {
                    return this._RouteValue;
                }
                set
                {
                    this.OnRouteValueChanging(value);
                    this._RouteValue = value;
                    this.OnRouteValueChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _RouteValue;
            partial void OnRouteValueChanging(string value);
            partial void OnRouteValueChanged();
            /// <summary>
            /// There are no comments for Property DisplayOrder in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public int DisplayOrder
            {
                get
                {
                    return this._DisplayOrder;
                }
                set
                {
                    this.OnDisplayOrderChanging(value);
                    this._DisplayOrder = value;
                    this.OnDisplayOrderChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private int _DisplayOrder;
            partial void OnDisplayOrderChanging(int value);
            partial void OnDisplayOrderChanged();
            /// <summary>
            /// There are no comments for Property Visible in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public bool Visible
            {
                get
                {
                    return this._Visible;
                }
                set
                {
                    this.OnVisibleChanging(value);
                    this._Visible = value;
                    this.OnVisibleChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private bool _Visible;
            partial void OnVisibleChanging(bool value);
            partial void OnVisibleChanged();
            /// <summary>
            /// There are no comments for Property Active in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public bool Active
            {
                get
                {
                    return this._Active;
                }
                set
                {
                    this.OnActiveChanging(value);
                    this._Active = value;
                    this.OnActiveChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private bool _Active;
            partial void OnActiveChanging(bool value);
            partial void OnActiveChanged();
            /// <summary>
            /// There are no comments for Property Created in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public global::System.DateTime Created
            {
                get
                {
                    return this._Created;
                }
                set
                {
                    this.OnCreatedChanging(value);
                    this._Created = value;
                    this.OnCreatedChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private global::System.DateTime _Created;
            partial void OnCreatedChanging(global::System.DateTime value);
            partial void OnCreatedChanged();
            /// <summary>
            /// There are no comments for Property CreatedBy in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string CreatedBy
            {
                get
                {
                    return this._CreatedBy;
                }
                set
                {
                    this.OnCreatedByChanging(value);
                    this._CreatedBy = value;
                    this.OnCreatedByChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _CreatedBy;
            partial void OnCreatedByChanging(string value);
            partial void OnCreatedByChanged();
            /// <summary>
            /// There are no comments for Property Updated in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public global::System.Nullable<global::System.DateTime> Updated
            {
                get
                {
                    return this._Updated;
                }
                set
                {
                    this.OnUpdatedChanging(value);
                    this._Updated = value;
                    this.OnUpdatedChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private global::System.Nullable<global::System.DateTime> _Updated;
            partial void OnUpdatedChanging(global::System.Nullable<global::System.DateTime> value);
            partial void OnUpdatedChanged();
            /// <summary>
            /// There are no comments for Property UpdatedBy in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string UpdatedBy
            {
                get
                {
                    return this._UpdatedBy;
                }
                set
                {
                    this.OnUpdatedByChanging(value);
                    this._UpdatedBy = value;
                    this.OnUpdatedByChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _UpdatedBy;
            partial void OnUpdatedByChanging(string value);
            partial void OnUpdatedByChanged();
            /// <summary>
            /// There are no comments for Property RowVersion in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public byte[] RowVersion
            {
                get
                {
                    if ((this._RowVersion != null))
                    {
                        return ((byte[])(this._RowVersion.Clone()));
                    }
                    else
                    {
                        return null;
                    }
                }
                set
                {
                    this.OnRowVersionChanging(value);
                    this._RowVersion = value;
                    this.OnRowVersionChanged();
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private byte[] _RowVersion;
            partial void OnRowVersionChanging(byte[] value);
            partial void OnRowVersionChanged();
            /// <summary>
            /// There are no comments for AreaRoles in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public global::System.Collections.ObjectModel.Collection<AreaRole> AreaRoles
            {
                get
                {
                    return this._AreaRoles;
                }
                set
                {
                    if ((value != null))
                    {
                        this._AreaRoles = value;
                    }
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private global::System.Collections.ObjectModel.Collection<AreaRole> _AreaRoles = new global::System.Collections.ObjectModel.Collection<AreaRole>();
            /// <summary>
            /// There are no comments for Controllers in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public global::System.Collections.ObjectModel.Collection<Controller> Controllers
            {
                get
                {
                    return this._Controllers;
                }
                set
                {
                    if ((value != null))
                    {
                        this._Controllers = value;
                    }
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private global::System.Collections.ObjectModel.Collection<Controller> _Controllers = new global::System.Collections.ObjectModel.Collection<Controller>();
            /// <summary>
            /// There are no comments for Reports in the schema.
            /// </summary>
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public global::System.Collections.ObjectModel.Collection<Report> Reports
            {
                get
                {
                    return this._Reports;
                }
                set
                {
                    if ((value != null))
                    {
                        this._Reports = value;
                    }
                }
            }
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private global::System.Collections.ObjectModel.Collection<Report> _Reports = new global::System.Collections.ObjectModel.Collection<Report>();
        }
    

    Wednesday, October 17, 2012 6:49 PM
  • As you can see everything looks fine (at least to my eyes); however, the exception is still thrown on the querying application side. The trigger that seems to make this happen is when a property is fully deleted from the model diagram (followed by rebuild, publish, and Update Service Reference). Then, even after recreating the property, the exception remains.

    So frustrating.

    Wednesday, October 17, 2012 7:05 PM
  • Hmm - as far as I can tell it looks OK.

    Just guesses:

    - After you update the service reference, make sure that you recompile the application and redeploy (whatever that means) the new binaries.

    - You could stop on the debugger when the exception happens and check what the IEdmStructuredType parameter has in terms of properties - if the one in question is there.

    If it's possible, you can send me a repro project to vitek.karas at microsoft dot com.

    Thanks,


    Vitek Karas [MSFT]

    Thursday, October 18, 2012 1:16 AM
    Moderator
  • I, of course, did the first suggestion. While I have already run it in debug, I was not looking specifically for the IEdmStructureType. I will try that next. If I still have found nothing, I'll work on building an example project. Thanks - I appreciate your time on this.
    Friday, October 19, 2012 4:13 AM
  • Ok wow. This is going to be embarrassing...

    The line-before-the-line, where I was instantiating my context object, was using a host file alias in the URI that was pointing to a different server - a server that had the older version of the service. That older version, of course, was before my change to the property.

    SMH. My first real post on here, and I look like an ID10T. ugh.

    Thanks so much for at least trying to resolve my imaginary bug!

    • Marked as answer by DevDelimited Sunday, October 21, 2012 12:41 AM
    Sunday, October 21, 2012 12:40 AM