public Person Create(string name, string city, string birthcity) { if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(city) || string.IsNullOrWhiteSpace(birthcity)) { return(null); } Person person = new Person(name, city, birthcity); _context.Add(person); _context.SaveChanges(); return(person); }
public static void initialize(PeopleDBContext context) { context.Database.EnsureCreated(); if (context.Poeples.Any()) { return; } else { context.Poeples.Add(new Person("Mattias", "Rävemåla", "Malmö")); context.SaveChanges(); } }