none
ORM versus SqlMetal - "OtherKey" RRS feed

  • Question

  • Can someone explain this behaviour and also tell me if there is something I can do to correct it please?

    When I generate my source code from the object-relation mapper  and then repeat it from SQLMetal I get differing results: the "OtherKey" is missing by SQLMetal.

    ORM

      [Association(Name="Role_User", Storage="_Role", ThisKey="RoleId", OtherKey="RoleId", IsForeignKey=true)]

    SQLMetal

      [Association(Name="Role_User", Storage="_Role", ThisKey="RoleId", IsForeignKey=true)]

    I am using Visual Studio 2008 SP1 and am using the "Visual Studio 2008 Command Prompt" to run. This is my command "sqlmetal /code:DataClasses.designer.cs /namespace:Blah DataClasses.dbml"

     

    Thanks.

    John

    Friday, September 9, 2011 9:24 AM

Answers

  • Hi, 

    Check the version of sqlmetal.exe that you are running.

    This issue occurs when using version: 3.5.21022.x (this was the version I had when I had the same issue)

    If you upgrade to 3.5.30729.x (or later) you should find the issue is resolved (You can just copy the .exe from a machine with the correct version)

     

    Note: I'm not exactly sure how I ended up with this old version, it may have been because I installed VS 2005 after having already installed VS 2008

    • Proposed as answer by JamesGBailey Wednesday, September 21, 2011 10:35 PM
    • Marked as answer by John T. Angle Thursday, September 22, 2011 8:09 AM
    Wednesday, September 21, 2011 10:34 PM

All replies

  • Hello,

    E:\Vs2010\VC>sqlmetal /namespace:"DataClasses1" /co
    de:"DataClasses1.designer.cs" /language:csharp "DataClasses1.dbml"
    

    I made a test on my side, everything looks OK. It didn't ignore OtherKey property in AssociationAttribute. I suggest you check SqlMetal.exe and double check if your syntax was correct or not. http://msdn.microsoft.com/en-us/library/bb386987.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.

    Monday, September 12, 2011 7:30 AM
  • Hi.

    It must have been a glitch on the machine I was using that day because I ran the exact command (see original post) on a new-build machine and, hey presto, the problem had gone.

    Thanks for your help.

    John.

    • Marked as answer by John T. Angle Saturday, September 17, 2011 7:32 PM
    • Unmarked as answer by John T. Angle Thursday, September 22, 2011 8:09 AM
    Saturday, September 17, 2011 7:32 PM
  • Hi, 

    Check the version of sqlmetal.exe that you are running.

    This issue occurs when using version: 3.5.21022.x (this was the version I had when I had the same issue)

    If you upgrade to 3.5.30729.x (or later) you should find the issue is resolved (You can just copy the .exe from a machine with the correct version)

     

    Note: I'm not exactly sure how I ended up with this old version, it may have been because I installed VS 2005 after having already installed VS 2008

    • Proposed as answer by JamesGBailey Wednesday, September 21, 2011 10:35 PM
    • Marked as answer by John T. Angle Thursday, September 22, 2011 8:09 AM
    Wednesday, September 21, 2011 10:34 PM
  • Thanks James. That explains it.
    Thursday, September 22, 2011 8:09 AM