移除EF表名公约,复数

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<System.Data.Entity.ModelConfiguration.Conventions.PluralizingTableNameConvention>();
        }

如果不加约束[Table("Product")],也没有移除复数公约的话,默认会Products表。  

    [Table("Product")]
    public partial class Product
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public int CategoryId { get; set; }

        public int Price { get; set; }

        public virtual Category Category { get; set; }
    }

 

posted @ 2022-04-02 13:15  江境纣州  阅读(24)  评论(0编辑  收藏  举报