SQL Server Set varbinary size in Entity Framework C#

oug3syen  于 2023-11-16  发布在  C#
关注(0)|答案(1)|浏览(146)

I am working with the code first approach, here is the POCO object I am using

public class Fotografia
{
    // Fotografía
    [Display(Name = "Fotografía")]
    public required byte[] fotografia { get; set; }
}

I want to set the max value for the varbinary value it creates, currently I've read other posts which specify that this way it should set by default the max value but my code generates

fotografia (PK, varbinary(900), not null)

Which is smaller than what I need to use

xqnpmsa8

xqnpmsa81#

Simply adding the [MaxLength] annotation doesn't work? Like this?

public class Fotografia
{
    // Fotografía
    [Display(Name = "Fotografía")]
    [MaxLength]
    public required byte[] fotografia { get; set; }
}

相关问题