首页 > 解决方案 > 在 EntityFramwork 6.2.0 我想创建阴影属性(是 EF 6 支持阴影属性)

问题描述

我的实体是

class Student
{
    public long Id{ get; set; }
}

数据库上下文是

 public class StudentContext:DbContext
 {
     public StudentContext():base("name=cnName") {}

     public DbSet<Student> Student{ get; set; }

     protected override void OnModelCreating(DbModelBuilder modelBuilder)
     { 
         modelBuilder.Entity<Student>().Property<DateTime> 
                                                ("CreatedOn");
         base.OnModelCreating(modelBuilder);
     }
}

例外是

语法错误无法从字符串转换为 System.Linq.Expressions.Expression

在下一行

modelBuilder.Entity<Student>().Property<DateTime>("CreatedOn");

我做错的是实体 6 支持影子属性。

标签: entity-framework-6

解决方案


推荐阅读