private void ConvertToDbConnect(List <ContactEntityMsg> contacts) { var employees = new List <Employee>(); foreach (var contact in contacts) { var employee = new Employee() { Id = contact.ContactId, UserName = contact.UserName, UserId = contact.UserId, Name = contact.Name, Number = contact.Number, IdCardNo = contact.IdCardNo, Gender = contact.Gender, }; employees.Add(employee); } using (var db = new ServiceDbContext(_dbOptions)) { db.BulkInsertOrUpdateOrDelete(employees); } }