private static void MigrateFromSqlToApi(ArtsdatabankenSIContext db, string apiEndPoint) { GetApiToken(); //migrate references var api = new ApiContext.Client(apiEndPoint, _apiClient); var batch = new List <Reference>(); foreach (var item in db.RfReference.Include(Reference => Reference.RfReferenceUsage)) { Console.Write(item.PkReferenceId + ","); var reference = MapToReference(item); batch.Add(reference); if (batch.Count() > 50) { var post = api.BulkAsync(batch); post.Wait(); batch = new List <Reference>(); } } if (batch.Count() > 0) { var post = api.BulkAsync(batch); post.Wait(); } }
static void Main(string[] args) { switch (args[0]) { case "migrate": //migrate using (var db = new ArtsdatabankenSIContext(args[1])) { var apiEndPoint = args[2]; MigrateFromSqlToApi(db, apiEndPoint); } break; } }