0

Main Class

Class TimeMaster  {
     Public string parameter1 { get; set; }
     Public string parameter2{  get; set; }
     Public string parameter3 { get; set; }
   }

I wanted backup of TimeMaster table so I created BTimeMaster table for backup so BTimeMaster class use all main table parameter and one added acdemicyear parameter extra.

Backup Class

    public class BTimeMaster : TimeMaster
    {
      [Required(ErrorMessage = "Required!")]
      [DisplayName("AcademicYear")]
      public string AcademicYear { get; set; }
   }

but when I called following function

         var firstContext = new TimetableContext();
        foreach (var first in firstContext.TimeMaster)
        {

        }

I cannot used like below if added [NotMapped] in class BTimeMaster and also want to map to a field and class BTimeMaster on the DB.

  var SecondContext = new BackupContext();
    foreach (var secondin SecondContext.BTimeMaster)
    {

    }

Error showed

enter image description here

which step I missed when inheritance for parent class when used [NotMapped] for AcademicYear then it worked but i wanted AcademicYear for my backup table

User
  • 1,334
  • 5
  • 29
  • 61
  • 1
    Does this answer your question? [EF Code First "Invalid column name 'Discriminator'" but no inheritance](https://stackoverflow.com/questions/6553935/ef-code-first-invalid-column-name-discriminator-but-no-inheritance) – Klaus Gütter Sep 15 '21 at 04:49
  • 1
    @KlausGütter not work if added [NotMapped] i cannot add in backup table *BTimeMaster* is another table where inherit some parameter and add addtional for backup table – User Sep 15 '21 at 09:31
  • @marc_s Is good way two use parent class parameter for secondary class – User Sep 15 '21 at 09:35

0 Answers0