static void Main(string[] args) { string[] codes = GetCodes(); Product product = null; using (ScanSystemsContext db = new ScanSystemsContext()) { db.Database.EnsureCreated(); product = db.Products.FirstOrDefault(); } Registrator reg = new Registrator(); //reg.Initialize(new CodeType() { Id = 3 }, product); foreach (var dm in codes) { reg.Registration(dm); } Console.ReadKey(true); }