It appears that your class should look like this:
public class DomesticQuater
{
public int ID { get; set; }
public Int64 QuaterNo { get; set; }
public String QuaterType { get; set; }
public int Block { get; set; }
public String Area { get; set; }
public String Street { get; set; }
public String AddtionalAddress { get; set; }
public virtual ElectricMeter Meter { get; set; }
}
You don't need the "int MeterId" line at all. EF will put it in there for you. You have the same problem in your
CommercialShop
and
Employee
classes.
Your
ElectricMeter
class also has a problem. The ID column name should be the name of the class with "Id" appended to it for a conventional configuration:
public class ElectricMeter
{
public int ElectricMeterID { get; set; }
public int MeterNo { get; set; }
public DateTime InstalledDate { get; set; }
[Column("MeterType")]
public bool IsDomestic { get; set; }
}
OR you can explicitly tag it as the key to the table, but just make sure you don't get
MeterId
and
MeterNo
confused in your code.
public class ElectricMeter
{
[Key]
public int MeterID { get; set; }
public int MeterNo { get; set; }
public DateTime InstalledDate { get; set; }
[Column("MeterType")]
public bool IsDomestic { get; set; }
}