static void Main(string[] args) { var options = new DbContextOptionsBuilder <DemoContext>() .UseInMemoryDatabase("TestDb") .Options; using (var context = new DemoContext(options)) { var car = new Car(); car.Owner = new Owner("Salesman"); // owner count 1 context.Cars.Add(car); Console.WriteLine(car.ToString()); context.SaveChanges(); } using (var context = new DemoContext(options)) { var client = new Client(context); var car = client.GetCarById(1); client.CarSoldToNewOwner(1, new Owner("Customer")); } }
public Client(DemoContext context) { _context = context; }