Fork me on GitHub

ef core schema 指定架构

不知道很少使用Schema模型还是怎么,居然搜帖子没人说,虽然很简单但是还是想记录一下坑

命名空间

using System.ComponentModel.DataAnnotations.Schema;

数据注释

[Table("blogs", Schema = "blogging")]
public class Blog
{
    public int BlogId { get; set; }
    public string Url { get; set; }
}

因为我们项目表结构通过架构来区分的,一直都没找到ef里面怎么设置,看了很多资料但是忽略了table就有这个参数 可能table有参构造并没有这属性造成的吧

地址:https://docs.microsoft.com/zh-cn/ef/core/modeling/relational/tables

默认架构设置:https://docs.microsoft.com/zh-cn/ef/core/modeling/relational/default-schema

记录下坑希望有人踩到直接就找到了

posted @ 2019-06-28 16:18  Hsyi  阅读(1250)  评论(0编辑  收藏  举报