相关疑难解决方法(0)

实体框架代码优先 - 为什么我不能这样更新复杂属性?

我正在使用Entity Framework 4.1(代码优先)开展一个小型示例项目.我的课程看起来像这样:

public class Context : DbContext
{
    public IDbSet<Person> People { get; set; }
    public IDbSet<EmployeeType> EmployeeTypes { get; set; }
}

public class Person
{
    [Key]
    public int Key { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }

    virtual public EmployeeType EmployeeType { get; set; }
}

public class EmployeeType
{
    [Key]
    public int Key { get; set; }
    public string Text { get; set; }

    virtual public …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework ef-code-first entity-framework-4.1

28
推荐指数
1
解决办法
1万
查看次数