HasData在基于继承的类上无法正常工作

时间:2018-10-07 16:38:10

标签: entity-framework .net-core asp.net-core-2.1

我有一个名为“ CurrencyPairComponent”的实体,它继承了

public class CurrencyPairComponent : RequestComponent

但是即使有了这个种子,它也不会出现在数据库表中。

entityTypeBuilder.HasData(
                new CurrencyPairComponent()
                {
                    Id = 1,
                    CurrencyPairId = 1,
                    ComponentType = ComponentType.Ask,
                    QueryComponent = "1",
                    RequestId = 1,
                    RequestComponentData = new List<RequestComponentDatum>(),
                    CreatedAt = DateTime.Now,
                    ModifiedAt = DateTime.Now,
                    DeletedAt = null
                },
                new CurrencyPairComponent()
                {
                    Id = 2,
                    CurrencyPairId = 1,
                    ComponentType = ComponentType.Bid,
                    QueryComponent = "0",
                    RequestId = 1,
                    RequestComponentData = new List<RequestComponentDatum>(),
                    CreatedAt = DateTime.Now,
                    ModifiedAt = DateTime.Now,
                    DeletedAt = null
                },
                new CurrencyPairComponent()
                {
                    Id = 3,
                    CurrencyPairId = 2,
                    ComponentType = ComponentType.Ask,
                    QueryComponent = "0",
                    RequestId = 2,
                    RequestComponentData = new List<RequestComponentDatum>(),
                    CreatedAt = DateTime.Now,
                    ModifiedAt = DateTime.Now,
                    DeletedAt = null
                }
            );
        }

Db Table

怎么回事?我是否使用了不正确的HasData?关于has been recently introduced in .NET Core 2.1.

的HasData用例,没有任何特定信息。

0 个答案:

没有答案