How to configure DbSet to match a specific table within a specific SqlServer schema?

The database that I need to create DAL for is designed with several schemas, which causes me some problems:

So, for example, we will consider these tables in two separate schemes (Suppliers, offers)

  • Suppliers. Suppliers
  • Suppliers.Types
  • Deals.Deals
  • Deals.Types

I have in 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; }
    }
}

but EF is disabled if there are two things called "Types", how can I fix these two issues using only DbSet?

NOTES: I am trying to get away from the .edmx file.

+3
source share
1 answer

, TableAttribute (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.tableattribute(v=vs .103).aspx) api ToTable() (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.tableattribute(v = vs .103).aspx)

0

All Articles