0
我在我的項目中有以下方法。實體框架地圖模型到表
public IEnumerable<T> GetAll()
{
return _context.Set<T>().ToList();
}
然後我的DbContext有這個..
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Entity<Product>.ToTable("Product");
}
這工作得很好,只要 「產品」 型號是同一個項目中。
但是,不同的客戶端將使用我的DataAccess層,他們將傳遞不同類型的模型。我如何告訴EntityFramework動態地將模型綁定到SQL服務器中的「表」。
他們可以提供自己的[EntityTypeConfiguration]類(http://www.entityframeworktutorial.net/code-first/entitytypeconfiguration-class.aspx)。 –
我很難找到它的一個例子 – Khan