如何在.net core3和ef core3中的上下文中为表名添加前缀?

时间:2019-10-15 09:41:52

标签: c# asp.net-core

如何在.net core3和ef core3中的上下文中为表名添加前缀? 我读了文件。我不明白五月天!

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Configuration;

namespace ZoLone.Logics
{
    public class DataContext: DbContext
    {
        public DataContext(DbContextOptions options) : base(options)
        {

        }

        //public DbSet<Student> Students { get; set; }

        public IEntityTypeConfiguration<DataContext> entityTypeConfiguration;
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可以使用schema

modelBuilder.HasDefaultSchema("School");

这将为您在此DBContext中的所有表加上前缀School.