我正在尝试将电子邮件格式存储在我DbContext
的原样中:
public class Context : DbContext
{
public DbSet<MailMessage> MessageFormats { get; set; }
}
尝试使用它时,我得到一个异常,因为MailMessage
没有 ID。我可以为 MailMessage 指定一个 Id 还是必须创建它的子类?
我正在尝试将电子邮件格式存储在我DbContext
的原样中:
public class Context : DbContext
{
public DbSet<MailMessage> MessageFormats { get; set; }
}
尝试使用它时,我得到一个异常,因为MailMessage
没有 ID。我可以为 MailMessage 指定一个 Id 还是必须创建它的子类?
Are you trying to store System.Net.Mail.MailMessage
objects in your database using EntityFramework? I've only ever seen people store their own classes. Your best option would be to create your own class that takes a MailMessage in its constructor and exposes the properties you want to save.