Base solution for your next web application
Open Closed

Postgresql Schema Name Change #5301


User avatar
0
FahrettinOzturk created

Hello all,

The migration tool creates all needed tables on PostgreSql database in "Public" schema which is default. I couldn't see any schema name property in config files. Can we change the name of the schema?

Thanks.


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Here are some information about modifying table schema

    modelBuilder.Entity<Blog>()
                .ToTable("blogs", schema: "blogging");
    
    class MyContext : DbContext
    {
        public DbSet<Blog> Blogs { get; set; }
    
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasDefaultSchema("blogging");
        }
    }
    

    More reference documents : [https://docs.microsoft.com/en-us/ef/core/modeling/relational/tables]) [https://docs.microsoft.com/en-us/ef/core/modeling/relational/default-schema])