Entity Framework 6 - Code First: table schema from classes' namespace

后端 未结 3 1081
死守一世寂寞
死守一世寂寞 2021-02-13 19:00

Does any know if one can set the table schema of code first classes based on the classes\' namespace?

For example, every class in namespace Core.Foo would

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-13 19:19

    In EF 6.2 or EF Core, use the Schema property to specify the schema name for a Db table as shown below:

    [Table("TableName", Schema = "Foo")]
    public class Entity
    {
        //Properties
    }
    

    Details Here

提交回复
热议问题