EF CodeFirst 之 Fluent API

如何访问Fluent API:

在自定义上下文类中重写OnModelCreating方法,在方法内调用。

注:用法基本一样,配置类中的this就相当于modelBuilder.Entity<Person>()

配置模型 Model-wide Configurations

modelBuilder.HasDefaultSchema("My");//将数据库架构名设置为My

配置实体 Entity Configurations  /  配置属性 Property Configurations

猜你喜欢

转载自www.cnblogs.com/1016391912pm/p/12064804.html