I have created a DBContext class in a .Net Standard 1.4 and have some code for entity configuration, in the OnModelCreating method, but it looks like this method is not getting called and I am getting an error complaining about a column name.
Here is my class:
public partial class TestContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Data Source=blah");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<TestTable>().HasKey(t => t.Id).HasName("TestTableId");
modelBuilder.Entity<TestTable>().ToTable("TestTable");
}
public virtual DbSet<TestTable> TestTable { get; set; }
}
public class TestTable
{
public Guid Id { get; set; }
public string Name { get; set; }
}
When I try to query this TestTable, I get an error saying invalid column name "Id"
And I don't have Id in the table, and I have TestTableId, and I was hoping the OnModelCreating code I got will take care of that mapping.
Any Ideas?