我开始使用 Entity Framework 6 并且遇到了动态模型的问题。我有以下模型:
public class EF6
{
public Guid Guid { get; set; }
public int Int2 { get; set; }
public string Str { get; set; }
public byte[] Doc { get; set; }
}
像这样添加到上下文中:
Entities ent = new Entities();
var dbSet = ent.Set<EF6>();
EF6 e = new EF6();
e.Guid = Guid.NewGuid();
e.Int2 = 123;
e.Str = "Hello World";
e.Doc = new byte[1] { 0 };
dbSet.Add(e);
但就dbSet.Add(e)
部分而言,我收到以下错误:The entity type EF6 is not part of the model for the current context.
有没有人有解决这个问题的方法?
编辑
后来我想用 IronPython 编写一些模型并将它们添加到dbSet.Add
.
编辑 2