Updating SQL schema failed... field uses the db-ref extension... referenced class does not use application identity

Thread is closed for posting
4 posts, 0 answers
  1. IT
    IT avatar
    41 posts
    Member since:
    Jan 2010

    Posted 25 Jun 2010 Link to this post

    New project, using VS2010 with ORM 2010.1.527 for the first time (previously VS2008 w/ 2009.3.1119)

    Trying a simple one-to-many class... and (suddenly) getting the following when trying to compile:-

    Error    1    OpenAccess Error: Telerik.OpenAccess: Updating SQL schema failed. The field 'colour' of class 'Meta.Catalogue.Product' uses the db-ref extension, but the referenced class 'Meta.Catalogue.Colour' does not use application identity. --> C:\Development\Meta\Meta\bin\Debug\Meta.dll:(resource)Meta.App.config:mapping-id=mssqlMapping/namespace[Meta.Catalogue]/class[Product]/field[colour]/db-ref="id"    MetaWeb    


    Here are relevant bits of code (only sections provided):

    App.config:-

              <class name="Product">
                <extension key="db-table-name" value="metaCatalogueProduct" />
                <extension key="db-key-generator" value="AUTOINC" />
                <field name="colour">
                  <extension key="db-ref" value="id">
                    <extension key="db-column">
                      <extension key="db-column-name" value="colour_id" />
                    </extension>
                  </extension>
                </field>
                <field name="finish">
                  <extension key="db-ref" value="id">
                    <extension key="db-column">
                      <extension key="db-column-name" value="finish_id" />
                    </extension>
                  </extension>
                </field>
                <field name="size">
                  <extension key="db-ref" value="id">
                    <extension key="db-column">
                      <extension key="db-column-name" value="size_id" />
                    </extension>
                  </extension>
                </field>
                <field name="style">
                  <extension key="db-ref" value="id">
                    <extension key="db-column">
                      <extension key="db-column-name" value="style_id" />
                    </extension>
                  </extension>
                </field>
              </class>
    ...
              <class name="Colour">
                <extension key="db-table-name" value="metaCatalogueColour" />
                <extension key="db-key-generator" value="AUTOINC" />
              </class>


    Product class:

    using Telerik.OpenAccess;

    namespace Meta.Catalogue
    {
        [Persistent(IdentityField = "id")]
        public class Product
        {
            private int id;
            [FieldAlias("id")]
            public int ID
            {
                get { return id; }
                set { id = value; }
            }

            private Style style;
            [FieldAlias("style")]
            public Style Style
            {
                get { return style; }
                set { style = value; }
            }

            private Colour colour;
            [FieldAlias("colour")]
            public Colour Colour
            {
                get { return colour; }
                set { colour = value; }
            }
    ...


    Colour class:

    using Telerik.OpenAccess;

    namespace Meta.Catalogue
    {
        [Persistent(IdentityField = "id")]
        public class Colour
        {
            private int id;
            [FieldAlias("id")]
            public int ID
            {
                get { return id; }
                set { id = value; }
            }

            private string name;
            [FieldAlias("name")]
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
        }
    }


    I've searched for this error message, and cannot find anything

    Thanks in advance for any help anyone can provide.












  2. Ady
    Admin
    Ady avatar
    589 posts

    Posted 25 Jun 2010 Link to this post

    Hello Aleks,

     The problem is in the mapping for the color field. Please remove the 'db-ref' extension from the field mapping. The db-column extension should be directly present under the field node

    <field name="colour">
                  <extension key="db-ref" value="id">
                    <extension key="db-column">
                      <extension key="db-column-name" value="colour_id" />
                    </extension>
                  </extension>
    </field>

    The mapping should look like this
    <field name="colour">
       <extension key="db-column">
               <extension key="db-column-name" value="colour_id" />
       </extension>
    </field>

    The 'db-ref' node is valid only when the class being referenced has multiple pk fields.

    Do let me know if that helps.

    Kind regards,
    Ady
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. IT
    IT avatar
    41 posts
    Member since:
    Jan 2010

    Posted 25 Jun 2010 Link to this post

    Ady,

    Thanks for your help.

    That seems to have done the trick.

    Is there a corresponding control in the forward mapping GUI that controls these elements in the XML? It seems I've done something at some stage that has either caused these elements to be added, or if they were already there, caused them to throw the exception.

    I notice I also intermittently get the following:-

    Error    6    OpenAccess: C:\Development\Meta\Meta\obj\Debug\Meta.dll: Error: Could not resolve: Telerik.OpenAccess.35.Extensions, Version=2010.1.527.2, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342        

    Running "Check Config" seems to fix it, but it will just pop up again a few compiles later.


    Best regards,
    Aleks


  4. Ady
    Admin
    Ady avatar
    589 posts

    Posted 28 Jun 2010 Link to this post

    Hello Aleks,

     These entries are managed by the Forward mapping dialog when you edit the mapping for a field. You should not normally need to manually edit it in the config file. I am not sure how you got these invalid entries in the config file. Did you, at any point, manually edit the mapping?

    Regarding the second error - it indicates that the Telerik.OpenAccess.35.Extensions assembly reference in the project references points to another (probably older) version of the assembly. The wizard is updating the reference to the latest version that is installed on your machine. Does this error occur even if you do not update to a new version? It should not.

    Sincerely yours,
    Ady
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top