0

我正在尝试将电子邮件格式存储在我DbContext的原样中:

public class Context : DbContext
{
    public DbSet<MailMessage> MessageFormats { get; set; }
}

尝试使用它时,我得到一个异常,因为MailMessage没有 ID。我可以为 MailMessage 指定一个 Id 还是必须创建它的子类?

4

1 回答 1

2

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.

于 2012-12-17T00:24:33.470 回答