private static void SeedFirstNames(NGDbContext dbContext) { string directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string basePath = Path.GetFullPath(Path.Combine(directoryPath, @"..\..\..\..")); string fullPath = Path.Combine(basePath, @"NG.Files\maleFirstNames.csv"); string[] lines = File.ReadAllLines(fullPath); List <Name> names = new List <Name>(lines.Length); for (int i = 0; i < lines.Length; i++) { int id = i + 1; var name = new Name() { Id = id, Record = lines[i], NameTypeId = 1 }; names.Add(name); } dbContext.MaleNames.AddRange(names); dbContext.SaveChanges(); }
private static void SeedTypes(NGDbContext dbContext) { dbContext.NameTypes.Add(new NameType() { Id = 1, Type = "male-first" }); dbContext.NameTypes.Add(new NameType() { Id = 2, Type = "male-last" }); dbContext.SaveChanges(); }