2

对于一些带有 EF 4.2 的 POCO,我有以下设置...

public class BaseItem
{
    [ScaffoldColumn(false)]
    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid Id { get; set; }

    /// <summary>
    /// The name of this item.
    /// </summary>
    [Required(AllowEmptyStrings = false)]
    [DisplayName("Name")]
    [MaxLength(255)]
    public string Name { get; set; }
}

public class Movie : BaseItem
{
    public string Description { get; set; }
}

使用 EF 迁移,我运行了 Add-Migration FirstDatabaseCreate 并获得了以下迁移...

CreateTable(
"Movie",
    c => new
    {
        Id = c.Guid(nullable: false),
        Name = c.String(nullable: false)
        Description = c.String(),

    })
.PrimaryKey(t => t.Id);

请注意,迁移脚本的 Name 字段中没有maxLength: 255,即使我在 BaseItem 上设置了MaxLength

这是迁移中的错误还是我错过了其他东西?

4

0 回答 0