3

我需要为其构建 DAL 的数据库设计有多个模式,这给我带来了一些问题:

因此,例如,在两个单独的模式(供应商、交易)中考虑这些表

  • 供应商.供应商
  • 供应商类型
  • 特卖。特卖
  • 交易类型

我有 C#

namespace Data.Entities.Suppliers 
{
    public class Suppliers { /* properties mapped to fields in Sql Server table Suppliers .Suppliers */ }
    public class Types { /* properties mapped to fields in Sql Server table Suppliers .Types */ }
}

namespace Data.Entities.Deals
{
    public class Deals { /* properties mapped to fields in Sql Server table Deals.Deals */ }
    public class Types { /* properties mapped to fields in Sql Server table Deals.Types */ }
}


namespace Data.Repositories 
{
    public class EfDataContext: DbContext 
    {
        public DbSet<Suppliers.Suppliers> Suppliers { get; set; }
        public DbSet<Suppliers.Types> SupplierTypes { get; set; }
        public DbSet<Deals.Deals> Deals{ get; set; }
        public DbSet<Deals.Types> DealTypes { get; set; }
    }
}

但是 EF 绊倒了两个名为“类型”的东西,我如何仅使用 DbSet 来消除两者的歧义?

注意:我试图摆脱拥有 .edmx 文件。

4

1 回答 1

0

要指定架构,您可以在类上使用 TableAttribute (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.tableattribute(v=vs.103).aspx) 或使用 fluent 配置模型带有 ToTable() 方法的 api (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.tableattribute(v=vs.103).aspx)

于 2012-05-04T17:15:47.420 回答