Extracting Information from information_schema through EF Core 3.x

This is a simple documentation on how to extract the information from information_schema.columns using EF Core. I’ve tried a number of suggestions however it didn’t worked until this.

What you need

  1. New View – Create a new view in your database that selects from information_schema.columns
  2. Code Changes

AppDbContext.cs

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity(mb =>
{
mb.HasNoKey();
mb.ToView(“vInformationSchemaColumns”);
});
}

After adding the two changes, add your migration file and you would be able to map the information