title: Entity Framework Core error not seen before Class.TempProperty is of type 'object' which is not supported by current database provider
body: <p>I am using Entity Framework Core <code>code-first</code> with fluent API entity configurations, in an ASP .NET MVC Core application. My code currently compiles, but when I run add-migration in the Package Manager Console, it gives the error below:</p>
  
  <blockquote>
    <p>The property 'Exam.TempId' is of type 'object' which is not supported
    by current database provider. Either change the property CLR type or
    manually configure the database type for it.</p>
  </blockquote>
  
  <p>Searching Google for this error yields no results. Can anybody here help please?</p>
  
  <p>"Exam" is a class in my domain model, but it doesn't have a "TempId" property so I guess that's something that Entity Framework is adding. It does have an "Id" property, but the type is int, not object. </p>
  
  <p>I'll start by sharing the Exam class and the Exam configuration class. I can share more code if required. I'd be really grateful for any advice you can provide to resolve the problem.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  using System.Linq;
  
  namespace MySite.Core.Models
  {
      public class Exam : ActivatableEntity
      {
          private int _numberOfQuestionsToBeAttempted;
  
          private Exam()
          {
              Topics = new Collection&lt;Topic&gt;();
          }
  
          public Exam(IUser createdByUser,
              string name,
              string description,
              double timeAllowedInMinutes,
              bool shuffleTopicsTogether = true) :
              base(createdByUser)
          {
              Name = name;
              Description = description;
              Topics = new Collection&lt;Topic&gt;();
              TimeAllowedInMinutes = timeAllowedInMinutes;
              ShuffleTopicsTogether = shuffleTopicsTogether;
          } 
  
          public string Name { get; private set; }
  
          public string Description { get; private set; }
  
          public double TimeAllowedInMinutes { get; private set; }
  
          public bool ShuffleTopicsTogether { get; private set; }
  
          public IEnumerable&lt;Question&gt; PossibleQuestions
          {
              get
              {
                  return Topics.SelectMany(t =&gt; t.PossibleQuestions);
              }
          }
  
          public int NumberOfQuestionsToBeAttempted
          {
              get
              {
                  if (_numberOfQuestionsToBeAttempted != 0) return _numberOfQuestionsToBeAttempted;
                  foreach (Topic topic in Topics)
                  {
                      _numberOfQuestionsToBeAttempted += topic.NumberOfQuestionsToBeAttempted;
                  }
                  return _numberOfQuestionsToBeAttempted;
              }
          }
  
          public IEnumerable&lt;Topic&gt; Topics { get;  }
  
          public void Update(IUser updatedByUser, string name, string description, double timeAllowedInMinutes, bool shuffleTopicsTogether = true)
          {
              Name = name ?? throw new ArgumentNullException(nameof(name));
              Description = description;
              TimeAllowedInMinutes = timeAllowedInMinutes;
              ShuffleTopicsTogether = shuffleTopicsTogether;
              Update(updatedByUser);
          }
      }
  }
  </code></pre>
  
  <p>Exam configuration class</p>
  
  <pre><code>using MySite.Core.Models;
  using Microsoft.EntityFrameworkCore.Metadata;
  using Microsoft.EntityFrameworkCore.Metadata.Builders;
  
  namespace MySite.Persistence.EntityConfiguration
  {
      public class ExamConfiguration
      {
          public ExamConfiguration(EntityTypeBuilder&lt;Exam&gt; entityBuilder)
          {
              entityBuilder.HasKey(e =&gt; e.Id);
  
              entityBuilder.HasOne(e =&gt; (ApplicationUser)e.CreatedByUser)
                  .WithMany()
                  .HasForeignKey(e =&gt; e.CreatedByUserId)
                  .OnDelete(DeleteBehavior.SetNull);
  
              entityBuilder.HasOne(e =&gt; (ApplicationUser)e.LastUpdatedByUser)
                  .WithMany()
                  .HasForeignKey(e =&gt; e.LastUpdatedByUserId)
                  .OnDelete(DeleteBehavior.SetNull);
  
              entityBuilder.Property(e =&gt; e.Name).IsRequired().HasMaxLength(50);
  
              entityBuilder.Property(e =&gt; e.Description).IsRequired().HasMaxLength(250);
  
              entityBuilder.HasMany(e =&gt; e.Topics)
                  .WithOne(t =&gt; t.Exam).OnDelete(DeleteBehavior.Cascade);
          }
      }
  }
  </code></pre>
  
  <p>As requested by posters, I'm adding the code for the base classes below:</p>
  
  <pre><code>using System;
  
  namespace MySite.Core.Models
  {
      public abstract class ActivatableEntity :
          UpdatableCreatableEntity,
          IActivatable
      {
          protected ActivatableEntity() { }
  
          protected ActivatableEntity(IUser createdByUser) : base(createdByUser) { }
  
          public int? LastActivatedByUserId { get; private set; }
          public IUser LastActivatedByUser { get; private set; }
          public DateTime? WhenLastActivated { get; private set; }
          public int? LastDeactivatedByUserId { get; private set; }
          public IUser LastDeactivatedByUser { get; private set; }
          public DateTime? WhenLastDeactivated { get; private set; }
          public bool IsActive { get; private set; }
  
          protected virtual void Activate(IUser activatedByUser)
          {
              LastActivatedByUser = activatedByUser ?? throw new ArgumentNullException(nameof(activatedByUser));
  
              LastActivatedByUserId = activatedByUser.Id;
              WhenLastActivated = DateTime.Now;
              IsActive = true;
          }
  
          protected virtual void Deactivate(IUser deactivatedByUser)
          {
              LastDeactivatedByUser = deactivatedByUser ?? throw new ArgumentNullException(nameof(deactivatedByUser));
  
              LastDeactivatedByUserId = deactivatedByUser.Id;
              WhenLastDeactivated = DateTime.Now;
              IsActive = false;
          }
      }
  
      public abstract class UpdatableCreatableEntity :
          CreatableEntity,
          IUpdatable
      {
          protected UpdatableCreatableEntity() { }
  
          protected UpdatableCreatableEntity(IUser createdByUser) : base(createdByUser) { }
  
          public int? LastUpdatedByUserId { get; private set; }
          public IUser LastUpdatedByUser { get; private set; }
          public DateTime? WhenLastUpdated { get; private set; }
  
          protected virtual void Update(IUser updatedByUser)
          {
              LastUpdatedByUser = updatedByUser ?? throw new ArgumentNullException(nameof(updatedByUser));
              LastUpdatedByUserId = updatedByUser.Id;
              WhenLastUpdated = DateTime.Now;
          }
      }
  
      public abstract class CreatableEntity :
          IIdentifiable,
          ICreatable
      {
          protected CreatableEntity() { }
  
          protected CreatableEntity(IUser createdByUser)
          {
              CreatedByUser = createdByUser ?? throw new ArgumentNullException(nameof(createdByUser));
              CreatedByUserId = createdByUser.Id;
              WhenCreated = DateTime.Now;
          }
  
          public int Id { get; private set; }
          public int? CreatedByUserId { get; private set; }
          public DateTime WhenCreated { get; private set; }
          public IUser CreatedByUser { get; private set; }
      }
  }
  </code></pre>