Change Entity Framework database schema map after using code first

后端 未结 2 1622
小鲜肉
小鲜肉 2021-01-23 11:28

I\'ve finished building my blog using EF and Code First.

EF was running against my local SQL Express instance, with [DBO] schema.

Now i want to publish

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 11:53

    EF will use dbo schema if you didn't configure the schema explicitly through data annotations or fluent API.

    [Table("MyTable", "MySchema")]
    public class MyEntity
    {
    
    }
    

    Or

    modelBuidler.Entity().ToTable("MyTable", "MySchema");
    

提交回复
热议问题