我有具有属性 CardType 的类 Person
public class Person{
protected Person(){}
public Person(CardType cardType){
cardType = CardType;
}
public CardType CardType { get; private set; }
... other properties ommited
}
public class CardType : Enumeration
{
public static CardType Amex = new CardType(1, "Amex");
public static CardType Visa = new CardType(2, "Visa");
public static CardType MasterCard = new CardType(3, "MasterCard");
public CardType(int id, string name)
: base(id, name)
{
}
}
我正在尝试使用 EF Core 映射 CardType 属性
public void Configure(EntityTypeBuilder<Person> builder)
{
builder.ToTable("Person");
builder.Property(x => x.CardType);
}
但我得到以下信息:
属性“Person.CardType”属于“CardType”类型,当前数据库提供程序不支持。更改属性 CLR 类型或使用“[NotMapped]”属性或使用“OnModelCreating”中的“EntityTypeBuilder.Ignore”忽略该属性。