public override void Generate() { var manufacturerNamesToBeAdded = new HashSet<string>(); // To be the name unique while (manufacturerNamesToBeAdded.Count != this.Count) { manufacturerNamesToBeAdded.Add(this.Random.GetRandomStringWithRandomLength(5, 20)); } int index = 0; this.Logger.LogMessage("Adding manufacturers"); foreach (var manufacturerName in manufacturerNamesToBeAdded) { var manufacturer = new Manufacturer { Name = manufacturerName, Country = this.Random.GetRandomStringWithRandomLength(2, 50) }; if (index % 100 == 0) { this.Logger.LogMessage("."); this.Database.SaveChanges(); } this.Database.Manufacturers.Add(manufacturer); index++; } this.Logger.LogMessage(" Manufacturers added!\n"); }
public override void Generate() { var manufacturersToBeAdded = new HashSet<string>(); while (manufacturersToBeAdded.Count != this.Count) { manufacturersToBeAdded.Add(this.Random.GetRandomStringWithRandomLength(5, 50)); } int index = 0; Console.WriteLine("Adding Manufacturers:"); foreach (var manufactureName in manufacturersToBeAdded) { var newManufacturer = new Manufacturer { Name = manufactureName, Country = this.Random.GetRandomStringWithRandomLength(2, 100) }; this.Database.Manufacturers.Add(newManufacturer); if (index % 100 == 0) { Console.Write("."); Database.SaveChanges(); } index++; } Console.WriteLine(); Console.WriteLine("Manufacturers Added!"); }