I am using Entity Framework 5 code first . There are 2 tables in my database, AvailPayPeriods and AvailPayPeriodsWeekly . Both of them look the same:
Period datetime not null
Since these two tables are identical in nature, I decided to create the following class to represent either 1 of 2:
public class PayPeriod : IEntity { public int Id { get; set; } public DateTime Period { get; set; } }
I am trying to configure 2. In my database context context, there is the following:
public DbSet<PayPeriod> WeeklyPayPeriods { get; set; } public DbSet<PayPeriod> MonthlyPayPeriods { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Configurations.Add(new WeeklyPayPeriodConfiguration());
My WeeklyPayPeriodConfiguration class:
class WeeklyPayPeriodConfiguration : EntityTypeConfiguration<PayPeriod> { internal WeeklyPayPeriodConfiguration() { this.ToTable("AvailPayPeriodsWeekly"); } }
When I call my repository to return weekly pay periods, I get the following error:
Multiple object sets per type are not supported. The object sets 'WeeklyPayPeriods' and 'MonthlyPayPeriods' can both contain instances of type 'ePaySlips.DomainModel.Entities.PayPeriod'.
How to match 2 with the corresponding tables?
Should I create separate classes called WeeklyPayPeriod and MonthlyPayPeriod ?
Brendan vogt
source share