-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAzureDevopsTrackerContext.cs
More file actions
37 lines (31 loc) · 1.39 KB
/
AzureDevopsTrackerContext.cs
File metadata and controls
37 lines (31 loc) · 1.39 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
using AzureDevopsTracker.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
namespace AzureDevopsTracker.Data.Context
{
public class AzureDevopsTrackerContext : DbContext, IDisposable
{
public AzureDevopsTrackerContext(DbContextOptions options) : base(options)
{ }
public DbSet<WorkItem> WorkItems { get; set; }
public DbSet<WorkItemChange> WorkItemsChange { get; set; }
public DbSet<TimeByState> TimeByStates { get; set; }
public DbSet<ChangeLogItem> ChangeLogItems { get; set; }
public DbSet<ChangeLog> ChangeLogs { get; set; }
public DbSet<WorkItemCustomField> CustomFields { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
foreach (var property in modelBuilder.Model.GetEntityTypes().SelectMany(
e => e.GetProperties().Where(p => p.ClrType == typeof(string))))
property.SetColumnType("varchar(200)");
modelBuilder.HasDefaultSchema(DataBaseConfig.SchemaName);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AzureDevopsTrackerContext).Assembly);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
optionsBuilder.UseSqlServer(DataBaseConfig.ConnectionsString);
}
}
}