i’m keep getting this error msg:
Exception Details: MySql.Data.MySqlClient.MySqlException: Unknown column ‘Extent1.RuleType’ in ‘field list’
my mapping:
public abstract class AlertRule
{
private DateTime? _updateDateTime = DateTime.Now;
[Key]
public int Id { get; set; }
public int TemplateId { get; set; }
public virtual AlertRuleTemplate Template { get; set; }
public string RuleType
{
get
{
if (Template == null)
return null;
return Template.Name;
}
}
}
public class AlertOutageRule:AlertRule
{
public virtual List<AlertRuleOutage> AlertRuleOutages { get; set; }
}
public class AlertMissingRule:AlertRule{}
public class AlertMetadataRule:AlertRule{}
public DbSet<AlertRule> AlertRules { get; set; }
modelBuilder.Entity<AlertRule>()
.Map<AlertOutageRule>(m => m.Requires("RuleType").HasValue("NewsOutage"))
.Map<AlertMetadataRule>(m => m.Requires("RuleType").HasValue("NewsMetadata"))
.Map<AlertMissingRule>(m => m.Requires("RuleType").HasValue("NewsMissing"));
//.Property(m => m.TemplateId).HasColumnType("int");
modelBuilder.Entity<AlertRule>().ToTable("AlertRule");
the
public string RuleTypedefined as read only (noset{..}).EF will not map this property with database. see Your DB schema it will generated only 2 column (Id, TemplateId)