Пример #1
0
        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);
        }
Пример #2
0
        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();
        }