-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvancedUsage.cs
More file actions
57 lines (51 loc) · 1.74 KB
/
Copy pathAdvancedUsage.cs
File metadata and controls
57 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#nullable enable
using System;
using System.Threading.Tasks;
using EfMigrationDiff.Services;
using EfMigrationDiff.Repositories;
using EfMigrationDiff.Configuration;
using Microsoft.Extensions.DependencyInjection;
/// <summary>
/// Advanced Usage Example:
/// Demonstrates configuring the service, handling errors, and using specific options.
/// </summary>
class AdvancedUsage
{
static async Task Main(string[] args)
{
var services = new ServiceCollection();
// Register services (including configuration)
services.AddScoped<GitRepository>();
services.AddScoped<MigrationRepository>();
services.AddScoped<MigrationDiffService>();
services.AddSingleton(new SchemaDiffOptions {
EnableDetailedLogging = true,
TimeoutSeconds = 30
});
var provider = services.BuildServiceProvider();
var diffService = provider.GetRequiredService<MigrationDiffService>();
try
{
Console.WriteLine("Running advanced migration analysis...");
// Performing comparison with custom options
var result = await diffService.CompareBranchesAsync(
"main",
"feature/complex-db-changes"
);
// Handle results based on content
if (result.HasConflicts)
{
Console.WriteLine("Conflicts detected! Analyzing...");
// Add custom logic to handle conflicts
}
}
catch (TimeoutException)
{
Console.WriteLine("The migration analysis timed out.");
}
catch (Exception ex)
{
Console.WriteLine($"An unexpected error occurred: {ex.Message}");
}
}
}