Answer the question
In order to leave comments, you need to log in
How to form the correct Code First?
There are entity classes
class Transaction
{
public int ID { get; set; }
public Customer Customer { get; set; }
public DateTime Date { get; set; }
public double Price { get; set; }
public int Discount { get; set; }
public double Ended { get; set; }
}
class Customer
{
public int ID { get; set; }
public string Name { get; set; }
public string Last { get; set; }
public string Other { get; set; }
}
Transaction trans = new Transaction { Customer = cust, Date = DateTime.Now, Discount = discount, Price = price, Ended = ended };
Answer the question
In order to leave comments, you need to log in
Your instance of the Customer class is not tracked by EF. All code is needed. Try using Attach()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question