Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[TestMethod]
public void InitializeDatabaseWithDataTest()
{
using (var context = new CarServiceContext(_options))
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
var car1 = new Car()
{
Producer = "Volkswagen",
Model = "Golf IV",
ProductionDate = new DateTime(2009, 01, 01),
IsOnWarranty = false
};
var car2 = new Car()
{
Producer = "Peugeot",
Model = "206",
ProductionDate = new DateTime(2000, 01, 01),
IsOnWarranty = false
};
context.Cars.AddRange(car1, car2);
context.SaveChanges();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment