none
BC30494 Line is too long - DB Migrations not usuable RRS feed

  • Question

  • VB-Code generated by Add-Migration command cannot be compiled. Inside the generated file timestamp_Name.Designer.vb I found the following code:

        Public ReadOnly Property IMigrationMetadata_Target() As String Implements IMigrationMetadata.Target
          Get
            Return "H4sIAAAAAAAAEA0... (more than 150'000 characters)"
          End Get
        End Property

    The String literal has (for my model) more than 150'000 characters, but VB allows max. 65535 characters per line. The literal should be splitted and joined during runtime. Better solution would be to put it into a resource, because there is another .NET limit regarding total amount of String literals.

    Without a correction is DB migration useless.

    When using C# similar code is generated. There it works. It looks like C# hasn't a max. line length limit.

    Kind regards

    Peter

    Monday, February 27, 2012 4:54 PM

Answers

  • Hi Ralf Peter Lucke,

    This is a known issue in EF4.3, it will be fixed in next version. Thanks for your understanding.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 5, 2012 2:46 AM
    Moderator

All replies

  • Hi Ralf Peter Lucke,

    Welcome to MSDN Forum.

    string in C# is also has a max length, it is 2,147,483,647. It is large enough to store 150,000 characters. IMigrationMetadata.Target is a property to get the state of the model after this migration is run. Everytime you do a micration will create a value to store the state. I'm not sure why it created such a long string in the project. After testing, I find when I do one more time migration, the value will be longer than last created one. I haven't find any document about how the value create, I will reserch to find whether my guess is correct.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, February 29, 2012 7:10 AM
    Moderator
  • Hello Allan

    I found out that the value reflects the model; it's not a journal of alterations.

    Example:

    - Take some model

    - Add a migration called M0 and update the database

    - Add a property to the model

    - Add a migration called M1 and update the database

    - Remove the property added previously

    - Add a migration called M2 and update the database

    The target string value of M0 is identical to the value of M2. The bottom line is that the length of the value is a function of the size of the model. My model has about 200 entites.

    Kind regards

    Peter

    Wednesday, February 29, 2012 8:17 AM
  • Hi Ralf Peter Lucke,

    Could you please post the exception message here? And, how many time do you execute Add-Migration command leads to the exception? I will involve my workmates to research this issue.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 1, 2012 5:53 AM
    Moderator
  • Hello Allen

    I have this problem after using Add-Migration for the first time in a project. The Add-Migration itself succeeds. But a following build of the project fails with the following compiler error:

    C:\SISA.Solutions\COMP.DeclareIT-trunk-LineTooLong\COMP.DeclareIT-trunk\Migrations\201203010830336_M0.Designer.vb(23) : error BC30494: Line is too long.

    For the latest test I used the brand-new EntityFramework 4.3.1.

    Kind regards

    Peter

    Thursday, March 1, 2012 8:39 AM
  • Hi Peter,

    I will research the issue and come back as soon as possible.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 1, 2012 8:57 AM
    Moderator
  • Hi Peter,

    I have consult the production team, you can tried to break the line. Use the line-continuation character, which is an underscore (_), at the point at which you want the line to break. The underscore must be immediately preceded by a space or a line terminator (carriage return). In some cases, you can omit the line-continuation character and the Visual Basic compiler will implicitly continue the statement on the next line of code. Here's the link below.

    How to: Break and Combine Statements in Code (Visual Basic)

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 2, 2012 2:07 AM
    Moderator
  • Hello Allen

    This is not an option. I don't want to spent much time in manually correcting bad code which has been created automatically by a tool.

    The problem is not that VB can't handle huge lines. The problem is that EF generates such huge lines.

    Kind regards

    Peter

    Friday, March 2, 2012 8:32 AM
  • Hi Ralf Peter Lucke,

    This is a known issue in EF4.3, it will be fixed in next version. Thanks for your understanding.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 5, 2012 2:46 AM
    Moderator