예제 #1
0
        public async Task EnsureInitialToDoAsync(string filePath)
        {
            bool hasRecords = await ToDo.AnyAsync();

            if (!hasRecords && !string.IsNullOrEmpty(filePath))
            {
                string jsonData = await File.ReadAllTextAsync(filePath);

                if (!string.IsNullOrEmpty(jsonData))
                {
                    List <ToDo> result = JsonSerializer.Deserialize <List <ToDo> >(jsonData);
                    await ToDo.AddRangeAsync(result);
                    await SaveChangesAsync();
                }
            }
        }