小编use*_*324的帖子

使用Code First迁移添加外键

添加迁移后尝试更新数据库时出错.

以下是添加迁移之前的类

public class Product
{
    public Product() { }

    public int ProductId { get; set; } 
    public string Name { get; set; }
    public decimal Price { get; set; }
    public bool Istaxable { get; set; }
    public string DefaultImage { get; set; }
    public IList<Feature> Features { get; set; }
    public IList<Descriptor> Descriptors { get; set; }
    public IList<Image> Images { get; set; }
    public IList<Category> Categories { get; set; }
}


public class Feature
{
    public int …
Run Code Online (Sandbox Code Playgroud)

entity-framework foreign-keys ef-migrations

19
推荐指数
4
解决办法
3万
查看次数