static Type GenerateTargetType(IEnumerable <IDictionary <string, Object> > dict, string name) { var first = dict.First(); var props = ToProperties(first); var type = ModelService.GenerateModelType(props, name); return(type); }
static void Main(string[] args) { var options = ParseArguments(args); var data = GetData(options.JsonFile).ToArray(); var targetType = GenerateTargetType(data, options.TableName); var context = CreateContext(options.ConnectionString, targetType); var realData = ModelService.Map(data, targetType); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.AddRange(realData); context.SaveChanges(); }