Stored Proc and Char parm RRS feed

  • Question

  • I don't know if this is known, but I figured I would post this to let people know, or get info on why this works this way:

    I have a DB that defines it's keys as CHAR(15) - Fix length strings. I created a SP with CHAR parms, imported the proc and mapped it to a EF Function.

    I ran the code and watched the execution in SQL profiler/QA.

    For some reason EF padded the CHAR(15) strings with endless empty strings. I didn't count them, but I am guessing it defined it as CHAR(8000). Only when I defined them as VARCHAR did it run properly in QA.

    Is this a known issue with EF?




    Wednesday, February 23, 2011 2:47 PM


  • Hi!

    I never use CHAR myself, but I had to try it :)

    And it seems like a problem with the generation of the EDM from the database for me that it doesn't set the MaxLength to 15 on the database parameter like it does on table columns, which it should have done.

    Anyway, if you open the edmx in an xml editor you could add MaxLength="15" to your parameter, and it will only pass 15 characters.

    I recommend you to report this on Microsoft Connect, so it may be fixed in a future version.

    Hope this helps,

    • Proposed as answer by Rune Gulbrandsen Wednesday, February 23, 2011 6:17 PM
    • Marked as answer by Jackie-Sun Wednesday, March 2, 2011 3:15 AM
    Wednesday, February 23, 2011 6:17 PM