• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / EntityFrameworkCore.Generator / 27827701138

19 Jun 2026 01:10PM UTC coverage: 71.692% (-0.07%) from 71.762%
27827701138

push

github

pwelter34
Handle exceptions in commands

985 of 1863 branches covered (52.87%)

Branch coverage included in aggregate %.

14 of 52 new or added lines in 3 files covered. (26.92%)

1 existing line in 1 file now uncovered.

4217 of 5393 relevant lines covered (78.19%)

1276.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.26
/src/EntityFrameworkCore.Generator/GenerateCommand.cs
1
using EntityFrameworkCore.Generator.Extensions;
2

3
using Microsoft.Extensions.Logging;
4

5
using Spectre.Console.Cli;
6

7
namespace EntityFrameworkCore.Generator;
8

9
public class GenerateCommand : AsyncCommand<GenerateSettings>
10
{
11
    private readonly ILogger<GenerateCommand> _logger;
12
    private readonly IConfigurationSerializer _serializer;
13
    private readonly ICodeGenerator _codeGenerator;
14

15
    public GenerateCommand(
4✔
16
        ILogger<GenerateCommand> logger,
4✔
17
        IConfigurationSerializer serializer,
4✔
18
        ICodeGenerator codeGenerator)
4✔
19
    {
20
        _logger = logger;
4✔
21
        _serializer = serializer;
4✔
22
        _codeGenerator = codeGenerator;
4✔
23
    }
4✔
24

25
    protected override async Task<int> ExecuteAsync(CommandContext context, GenerateSettings settings, CancellationToken cancellationToken)
26
    {
27
        try
28
        {
29
            var workingDirectory = settings.WorkingDirectory ?? Environment.CurrentDirectory;
4!
30
            var configurationFile = settings.OptionsFile ?? ConfigurationSerializer.OptionsFileName;
4!
31

32
            var configuration = _serializer.Load(workingDirectory, configurationFile);
4✔
33
            if (configuration == null)
4!
34
            {
NEW
35
                _logger.LogInformation("Using default options");
×
NEW
36
                configuration = new Serialization.GeneratorModel();
×
37
            }
38

39
            // override options
40
            if (settings.ConnectionString.HasValue())
4✔
41
                configuration.Database.ConnectionString = settings.ConnectionString;
4✔
42

43
            if (settings.Provider.HasValue)
4!
NEW
44
                configuration.Database.Provider = settings.Provider.Value;
×
45

46
            if (settings.Extensions.HasValue)
4!
NEW
47
                configuration.Data.Query.Generate = settings.Extensions.Value;
×
48

49

50
            if (settings.Models.HasValue)
4!
51
            {
NEW
52
                configuration.Model.Read.Generate = settings.Models.Value;
×
NEW
53
                configuration.Model.Create.Generate = settings.Models.Value;
×
NEW
54
                configuration.Model.Update.Generate = settings.Models.Value;
×
55
            }
56

57
            if (settings.Mapper.HasValue)
4!
NEW
58
                configuration.Model.Mapper.Generate = settings.Mapper.Value;
×
59

60
            if (settings.Validator.HasValue)
4!
NEW
61
                configuration.Model.Validator.Generate = settings.Validator.Value;
×
62

63
            // convert to options format to support variables
64
            var options = OptionMapper.Map(configuration);
4✔
65

66
            var result = await _codeGenerator.GenerateAsync(options);
4✔
67

68
            return result ? 0 : 1;
4✔
69
        }
NEW
70
        catch (Exception ex)
×
71
        {
NEW
72
            _logger.LogError(ex, ex.Message);
×
NEW
73
            return 1;
×
74
        }
75
    }
4✔
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc