SUSER_SID() SQL Default Column with Entity Framework Insert Data not working RRS feed

  • Question

  • Hi,
    issue is with Default SQL Value = suser_sid() 

    I checked the possibility StoreGeneratedPattern is Identity and I tried to add this suser_sid() in entity model from designer but it creates an error msgs..

    in xml of this model property is describe like...
    <Property Name="TenantID" Type="varbinary(max)" StoreGeneratedPattern="Identity" /> 

    so, can you tell me what amendment, we should do to resolved this ? 

    really really thanks if you can provide the resolution..

    Regards, Brijesh Shah

    Wednesday, October 3, 2012 12:38 PM

All replies

  • Hi Team,

    Have i posted this in wrong forum or I am the first who get this issue in Entity Framework with Default SQL Value of SUSER_SID()... ?

    Need your help/suggestion please...

    Regards, Brijesh Shah

    Saturday, October 6, 2012 6:14 AM
  • Hi I tried to change my code like VarBinary(Max) to Varbinary(100) and also change the property attribute in entity framework to 


    But When I insert the record in that table... it insert 0x01 in that Column.

    When i Insert that using Store Procedure it somewhat like 0x010500000000000515000000BB4573748253F83B160C91C8F4010000 

    So, I suppose still something is missing ? Can you check that at your end? Any Suggestion? I really need a help as i hang up here.

    Regards, Brijesh Shah

    Saturday, October 6, 2012 12:41 PM
  • Hi Team, 
    I notice one thing...

    When i change Varbinary DataType to Varchar in SQL Property and SUSER_SID to SUSER_SNAME ... It works with Entity Framework.
    Now I have a doubt that Default SQL Property with VarBinary DataType has an issue with Entity Framework instead of SUSER_SID. 

    Any Idea ??

    Regards, Brijesh Shah

    Monday, October 8, 2012 9:10 AM
  • Hi Brijesh,

    Welcome to the MSDN forum.

    If you use StoreGeneratedPattern="Identity", you are not required to assign a value to this property. If you use StoreGeneratedPattern="Computed", you also are not required to pass a value to this column explicitly. Please refer to this page: http://msdn.microsoft.com/en-us/library/system.data.metadata.edm.storegeneratedpattern.aspx

    You said using store procedure failed. Could you please provide some code snippet?

    If I have anything misunderstood, please feel free to let me know and provide the specific steps (code snippet is better) to reproduce your problem.

    Good day.

    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 8, 2012 1:23 PM
  • Hi,

    What if you try SQL Server profiler to see what happens ?  How do you see this 0x01 value ? It should happen entirely server side so EF should play no role in that except perhaps in retrieving the value client side (this is why I'm asking where you do see that 0x01 was generated, are you sure you just don't look at the first byte ?)

    Have you dropped the identity property ? AFAIK this is only for auto incremented value (or do you have 0x02 when inserting another record ?)...

    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Tuesday, October 9, 2012 9:35 AM