I have two classes in my Pocos
public class Listing
{
public int ListingId { get; set; }
[ForeignKey("Seller")]
public int SellerId { get; set; }
public virtual User Seller { get; set; }
[Required]
public string ItemCategory { get; set; }
[Required]
public string ItemName { get; set; }
[Required]
public decimal Cost { get; set; }
public DateTime DateOfPublish { get; set; }
[Required]
public bool SaleStatus { get; set; }
[ForeignKey("Buyer")]
public Nullable<int> BuyerId { get; set; }
public virtual User Buyer { get; set; }
}
And
public class User
{
public int UserId { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string SecondName { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string Password { get; set; }
public string PhoneNumber { get; set; }
public string Address { get; set; }
public virtual ICollection<Listing> Listings { get; set; }
When I migrate this onto the database I get BuyerId, SellerId and User_UserId
The User_UserId column is totally unnecessary but I am not sure what to do with my code in order to remove it.