示例#1
0
        static int Main(string[] args)
        {
            MigrationOptions options = null;

            try
            {
                if (args == null || args.Length < 2)
                {
                    Console.WriteLine("Usage:");
                    Console.WriteLine("SqlDatabaseCopy.exe <sourceConnectionString> <targetConnectionString> [-SchemaOnly | -DataOnly] [-NoLog]");
                    return(-1);
                }

                options = GetOptions(args);
                var handler = new MigrationHandler(options);
                handler.Process();
                return(HandleErrors(handler));
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
                options?.Log?.WriteLine(ex.ToString());
                return(-1);
            }
            finally
            {
                options?.Log?.Dispose();
            }
        }
示例#2
0
        static int HandleErrors(MigrationHandler handler)
        {
            int errorCount = 0;

            foreach (var item in handler.Items.Where(item => !item.Succeed))
            {
                errorCount++;
                if (item.LastError != null)
                {
                    ConsoleHelper.WriteError($"{item}: " + item.LastError.Message);
                }
            }

            return(errorCount);
        }