Base solution for your next web application
Open Closed

AbpSettings table change #4820


User avatar
0
vladsd created

Is there a way to change the MaxValueLength

[MaxLength(MaxValueLength)]
public virtual string Value { get; set; }

I need to extend to 4000 and abp default is 2000

Thanks.


3 Answer(s)
  • User Avatar
    0
    vladsd created

    I did manual update with, is there other way?

    public partial class MySettings : Migration
        {
            protected override void Up(MigrationBuilder migrationBuilder)
            {
                migrationBuilder.AlterColumn<string>(
                 name: "Value",
                 table: "AbpSettings",
                 nullable: true,
                 maxLength: 4000,
                 oldClrType: typeof(string),
                 oldMaxLength: 2000,
                 oldNullable: true);
            }
    
            protected override void Down(MigrationBuilder migrationBuilder)
            {
                migrationBuilder.AlterColumn<string>(
                 name: "Value",
                 table: "AbpSettings",
                 nullable: true,
                 maxLength: 2000,
                 oldClrType: typeof(string),
                 oldMaxLength: 4000,
                 oldNullable: true);
            }
        }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @vladsd,

    You can do it in the onModelCreating of your dbContext. So, add migration command will produce related migration for you.

    Example <a class="postlink" href="https://docs.microsoft.com/en-us/ef/core/modeling/max-length#fluent-api">https://docs.microsoft.com/en-us/ef/cor ... fluent-api</a>.

  • User Avatar
    0
    vladsd created

    Thanks @ismcagdas, got it, I used it for other properties. Fluent is a good addition to EF apis.