我有一个简单的课程:
public class TestClass<T> {
public int ID { get; set; }
public T Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用EF Code First和Repository模式将这种元素保存到SQL数据库中?
编辑:似乎无法使用-notation创建DbSet.例如
public class UnitOFWorkTestContext : DbContext {
...
public DbSet<TestClass<int>> TestClass_Int { get; set; }
...
}
Run Code Online (Sandbox Code Playgroud)
给出错误:
未映射类型'UnitOFWorkTest.Models.TestClass`1 [System.Int32]'.使用Ignore方法或NotMappedAttribute数据批注检查未明确排除类型.验证类型是否已定义为类,不是原始类,嵌套类还是通用类,并且不从EntityObject继承.