public static EFCoreGeneratorOptions GetOptions(EFCoreGeneratorOptions options = null) { options = options ?? new EFCoreGeneratorOptions(null); while (string.IsNullOrEmpty(options.InputJsonSchema)) { Console.WriteLine($"[Choose an Input JSON Schema File]"); Console.Write($"Input file: "); options.InputJsonSchema = Console.ReadLine(); if (!File.Exists(options.InputJsonSchema)) { Console.WriteLine($"File {options.InputJsonSchema} does not exist"); options.InputJsonSchema = null; continue; } options.InputJsonSchema = new FileInfo(options.InputJsonSchema).FullName; } while (string.IsNullOrEmpty(options.TargetFolder)) { Console.WriteLine($"[Choose a Target Folder]"); Console.Write($"Target Folder: "); options.TargetFolder = Console.ReadLine(); } while (string.IsNullOrEmpty(options.EntitiesNamespace)) { Console.WriteLine($"[Choose a Namespace]"); Console.Write($"Namespace: "); options.EntitiesNamespace = Console.ReadLine(); } while (string.IsNullOrEmpty(options.ContextName)) { Console.WriteLine($"[Choose a DbContext Name]"); Console.Write($"DbContext Name: "); options.ContextName = Console.ReadLine(); } return(options); }
public EFCoreGeneratorOptions ToOptions() { var options = new EFCoreGeneratorOptions(this.Input); // if not provided EFCoreGeneratorConsoleHelper.GetOptions will ask for it if (!string.IsNullOrEmpty(this.TargetFolder)) { options.TargetFolder = this.TargetFolder; } else { options.TargetFolder = Directory.GetCurrentDirectory(); } if (!string.IsNullOrEmpty(this.Namespace)) { options.EntitiesNamespace = this.Namespace; } if (!string.IsNullOrEmpty(this.DbContextName)) { options.ContextName = this.DbContextName; } return(options); }
public EFCoreGenerator(EFCoreGeneratorOptions options) { _options = options; schema = Newtonsoft.Json.JsonConvert.DeserializeObject <LogicalSchema>(File.ReadAllText(_options.InputJsonSchema)); //schema.Tables = schema.Tables.Select(t => Map<LogicalTable, Table>(t)).ToList<Table>(); }