6
您如何明確地告訴EF某個表位於特定模式中?引用實體框架中的表的模式名稱
例如,AdventureWorks數據庫定義了Production.Product表。當使用OnModelCreating
方法,我用下面的代碼:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
EntityTypeConfiguration<Product> config = modelBuilder.Entity<Product>();
config.HasKey(p => p.ProductID);
config.Property(p => p.Price).HasColumnName("ListPrice");
config.ToTable("Product");
}
然而,在運行時,它說,它Invalid object name: dbo.Product
。
我曾嘗試:
config.ToTable("Production.Product");
//and
config.HasEntityName("Production");
,但都失敗也是如此。