【发布时间】:2012-10-21 18:20:58
【问题描述】:
我想要一个字符串列表,并使用 EF-CodeFirst 将它们保存到数据库或从数据库加载它们。这是我的 DbContext 类:
public class KeysDbContext : DbContext
{
public DbSet<string> Keys { get; set; }
}
但是当我尝试运行代码时,我得到了这个异常:System.InvalidOperationException : The type 'System.String' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.
我该如何解决这个问题?
【问题讨论】:
标签: c# entity-framework c#-4.0 ef-code-first