Using Entity Framework 6 with Multiple DB Schemas but using One DBContext

后端 未结 5 1823
甜味超标
甜味超标 2020-12-13 17:43

I have an application using EF as ORM. The database used to have one schema, dbo and everything was working fine. I recently organized my tables into 4 different schemas. So

5条回答
  •  遥遥无期
    2020-12-13 18:11

    In addition to the responce of Gert Arnold, you can also use Table attribute in your entity:

    using System.ComponentModel.DataAnnotations.Schema;
    
    [Table("t_Department", Schema = "school")]
    public class Department
    {
        public int Id { get; set; }
    
        public string Name { get; set; }
    }
    

提交回复
热议问题