a Table cant have more than one primary key but it cant have more than one forein keys.if there are more than one primary keys an error of more than one identity will occur.
this is the solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Template.Data
{
public class CustomerDB
{
[Key]
public int id { get; set; }
[Required(ErrorMessage = "Enter Num:")]
[Display(Name = "Customer name:")]
public string Name { get; set; }
[Required]
[Display(Name = "Customer surname:")]
public string Surname { get; set; }
[Required]
[Display(Name = "Email:")]
public string email { get; set; }
[Required]
[Display(Name = "Cellphone No:")]
public string cellphone { get; set; }
[Required(ErrorMessage = "Choose Car Number:")]
public int mID { get; set; }
[ForeignKey("mID")]
public virtual Moto moto { get; set; }
public string insured { get; set; }
[Required]
[Display(Name = "Licence Number:")]
[RegularExpression(@"^\$?\d+(\.(\d{2}))?$")]
public string licenceNo { get; set; }
[Required]
[Display(Name = "Company Name:")]
public string companyName { get; set; }
[Display(Name = "Fax No:")]
[RegularExpression(@"^\$?\d+(\.(\d{2}))?$")]
public string faxNo { get; set; }
public string unisured { get; set; }
[RegularExpression(@"^\$?\d+(\.(\d{2}))?$")]
[Display(Name = "Report NO:")]
public string accidentReportNo { get; set; }
[Display(Name = "Place of accident:")]
public String placeOfAccident { get; set; }
[Display(Name = "Police station name:")]
public string policeStationName { get; set; }
[Display(Name = "Police station phone:")]
public string policeStationTelNo { get; set; }
}
}