I have manually mapped a pre-existing table to a model and dbcontext
namespace App.Monitoring.DbContext
{
using Microsoft.EntityFrameworkCore;
using App.Monitoring.DbContext.Models;
public partial class Context: DbContext
{
public virtual DbSet<tDataLoad> tDataLoad { get; set; }
public Context(DbContextOptions<Context> options) :
base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<tDataLoad>(entity =>
{
entity.HasIndex(e => new { e.DataLoad_Id})
.IsUnique();
entity.Property(e => e.DataLoad_Id)
.IsRequired()
.HasMaxLength(255);
});
}
}
}
But when I’m trying to access table
_dataContext.tDataLoad.ToList();
I keep getting
>Solution :
You are likely missing the schema specification in your mapping. Please use the following for proper configuration.
entity.ToTable("tDataLoad", "log");

