Esempio n. 1
0
        static int Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    var builder           = new EfCoreModelBuilder();
                    var migrationsBuilder = new EfCoreMigrationsBuilder();

                    List <Tuple <string, string> > result;

                    if (args.Contains("ddl") && args.Count() >= 3)
                    {
                        result = builder.GenerateDatabaseCreateScript(args[1], args[2]);
                    }
                    else if (args.Contains("migrationstatus") && args.Count() >= 3)
                    {
                        result = migrationsBuilder.GenerateMigrationStatusList(args[1], args[2]);
                    }
                    else if (args.Contains("migrate") && args.Count() >= 4)
                    {
                        result = migrationsBuilder.Migrate(args[1], args[2], args[3]);
                    }
                    else if (args.Contains("scriptmigration") && args.Count() >= 4)
                    {
                        result = migrationsBuilder.ScriptMigration(args[1], args[2], args[3]);
                    }
                    else if (args.Contains("addmigration") && args.Count() >= 7)
                    {
                        result = migrationsBuilder.AddMigration(args[1], args[2], args[3], args[4], args[5], args[6]);
                    }
                    else
                    {
                        result = builder.GenerateDebugView(args[0], args[1]);
                    }
                    foreach (var tuple in result)
                    {
                        Console.Out.WriteLine("DbContext:");
                        Console.Out.WriteLine(tuple.Item1);
                        Console.Out.WriteLine("DebugView:");
                        Console.Out.WriteLine(tuple.Item2);
                    }
                }
                else
                {
                    Console.Out.WriteLine("Error:");
                    Console.Out.WriteLine("Invalid command line");
                    return(1);
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error:");
                Console.Out.WriteLine(ex);
                return(1);
            }
        }
Esempio n. 2
0
        public static int Main(string[] args)
        {
#pragma warning disable CA1031 // Do not catch general exception types
            try
            {
                Console.OutputEncoding = Encoding.UTF8;

                if (args == null)
                {
                    throw new ArgumentNullException(nameof(args));
                }

                if (args.Length > 0)
                {
                    List <Tuple <string, string> > result;

                    if (args.Contains("ddl") && args.Length >= 3)
                    {
                        result = EfCoreModelBuilder.GenerateDatabaseCreateScript(args[1], args[2]);
                    }
#if CORE50 || CORE60
                    else if (args.Contains("contextlist") && args.Length >= 3)
                    {
                        result = EfCoreCompareBuilder.GenerateDbContextList(args[1], args[2]);
                    }
                    else if (args.Contains("schemacompare") && args.Length >= 5)
                    {
                        result = EfCoreCompareBuilder.GenerateSchemaCompareResult(args[1], args[2], args[3], args[4]);
                    }
#endif
                    else if (args.Contains("migrationstatus") && args.Length >= 3)
                    {
                        result = EfCoreMigrationsBuilder.GenerateMigrationStatusList(args[1], args[2]);
                    }
                    else if (args.Contains("migrate") && args.Length >= 4)
                    {
                        result = EfCoreMigrationsBuilder.Migrate(args[1], args[2], args[3]);
                    }
                    else if (args.Contains("scriptmigration") && args.Length >= 4)
                    {
                        result = EfCoreMigrationsBuilder.ScriptMigration(args[1], args[2], args[3]);
                    }
                    else if (args.Contains("addmigration") && args.Length >= 7)
                    {
                        result = EfCoreMigrationsBuilder.AddMigration(args[1], args[2], args[3], args[4], args[5], args[6]);
                    }
                    else
                    {
                        result = EfCoreModelBuilder.GenerateDebugView(args[0], args[1]);
                    }

                    foreach (var tuple in result)
                    {
                        Console.Out.WriteLine("DbContext:");
                        Console.Out.WriteLine(tuple.Item1);
                        Console.Out.WriteLine("DebugView:");
                        Console.Out.WriteLine(tuple.Item2);
                    }
                }
                else
                {
                    Console.Out.WriteLine("Error:");
                    Console.Out.WriteLine("Invalid command line");
                    return(1);
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error:");
                Console.Out.WriteLine(ex);
                return(1);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }