MVC3 naming a column beginning with a number

前端 未结 3 919
野的像风
野的像风 2021-01-22 01:16

I am new to MVC3 C#. I need to have a column in the database called 3DSecureStatus for legacy purposes.

When I call the column this and insert in the applic

相关标签:
3条回答
  • 2021-01-22 01:40

    This is actually an Entity Framework error rather then an MVC error. It looks like from a bit of googling that underscores as the start of Code First field names are invalid and don't work. If you can, try putting a letter in front of it.

    0 讨论(0)
  • 2021-01-22 01:47

    Use the Column attribute to specify the database column name

    [Column("3DSecureStatus")]
    public string ThreeDSecureStatus { get; set; }
    

    Or use fluent mapping like

    Property(x => x.ThreeDSecureStatus).HasColumnName("3DSecureStatus");
    
    0 讨论(0)
  • 2021-01-22 01:51

    Rename _3DSecureStatus to something else.

    Entity Framework Code First does not allow properties/columns to have underscores or numbers in the beginning of the name.

    So you have to change this until this is fixed.

    0 讨论(0)
提交回复
热议问题