【发布时间】:2021-07-29 07:28:16
【问题描述】:
我将这些类作为我的领域模型:
public class Ticket
{
public Guid Id { get; set; }
public Guid ParentId { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
public string TicketStatus { get; set; }
public User SenderUserId { get; set; }
public User ReciverrUserId { get; set; }
public DateTime SubmitDate { get; set; }
}
public class User
{
public Guid Id { set; get; }
public DateTime SubmitDate { set; get; }
public string Fullname { set; get; }
public string Permission { set; get; }
public string Role { set; get; }//admin/agent/merchant
public string Password { set; get; }
public string NationalCode { set; get; }
public string Email { set; get; }
public string Telephone { set; get; }
public string Mobile { set; get; }
public string Address { set; get; }
public CountrySection Provience { set; get; }
public CountrySection City { set; get; }
//public Department Department { set; get; }
public CountrySection Town { set; get; }
public ICollection<Merchant> Stores { set; get; }
public ICollection<Invoice> Invoices { set; get; }
public ICollection<Ticket> Tickets { set; get; }
}
当我添加迁移时,我收到此错误:
无法确定“用户”类型的导航“Ticket.SenderUserId”表示的关系。手动配置关系,或使用“[NotMapped]”属性或使用“OnModelCreating”中的“EntityTypeBuilder.Ignore”忽略此属性
【问题讨论】:
-
您是否尝试按照错误提示进行操作?
-
尝试遵循 EF 所期望的命名约定:
SenderUserId->SenderUser,ReciverrUserId->ReceiverUser -
@abdusco 我按你说的改了名字,但同样的错误
-
DbContext.OnModelConfiguring有配置吗? -
@abdusco 不,我没有
标签: c# entity-framework asp.net-core .net-core entity-framework-core