基本上我創建了一個父變量的實體,我顯然希望將其包含在存儲實體的表中。EF中的繼承 - 如何在實體中包含父變量
這裏是父母的定義:
public class ProtectedProperty
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int PropertyId { get; set; }
[Required]
public string SubId { get; set; }
public int Downloads { get; set; }
[Required]
public UserProfile Owner { get; set; }
[Required]
public string Name { get; set; }
[Required]
public ProtectedPropertyType Type { get; set; }
}
下面是從父母繼承的財產(這其中有一個數據庫中的表):
[Table("ProtectedPassword")]
public class ProtectedPassword : ProtectedProperty
{
[Required]
//[StringLength(maximumLength:56)]
[MinLength(3)]
[MaxLength(20)]
public string Password { get; set; }
public ProtectedPassword(string name, UserProfile owner, string password)
{
Name = name;
Owner = owner;
Password = password;
SubId = PublicUtility.GenerateRandomString(8, 0);
Type = ProtectedPropertyType.Password;
}
問題然而這當我查看數據庫中的表定義時,我只能看到ProtectedPassword的2個屬性: Password和PropertyId
我想要其他變量(包括所有者,姓名等)