-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLoggingDbContext.cs
More file actions
62 lines (43 loc) · 1.99 KB
/
LoggingDbContext.cs
File metadata and controls
62 lines (43 loc) · 1.99 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
58
59
60
61
62
// Copyright (c) Source Tree Solutions, LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Author: Joe Audette
// Created: 2016-11-10
// Last Modified: 2016-11-10
//
using cloudscribe.Logging.Models;
using Microsoft.EntityFrameworkCore;
namespace cloudscribe.Logging.EFCore.pgsql
{
public class LoggingDbContext : LoggingDbContextBase, ILoggingDbContext
{
public LoggingDbContext(
DbContextOptions<LoggingDbContext> options) : base(options)
{
// we don't want to track any logitems because we dont edit them
// we add them delete them and view them
//ChangeTracker.AutoDetectChangesEnabled = false;
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.HasSequence<long>("LogIds")
.StartsAt(1)
.IncrementsBy(1);
modelBuilder.HasPostgresExtension("uuid-ossp");
modelBuilder.Entity<LogItem>(entity =>
{
entity.ToTable("cs_SystemLog");
entity.HasKey(p => p.Id);
entity.Property(p => p.Id).IsRequired();
entity.Property(p => p.LogDateUtc).HasColumnName("LogDate");
entity.Property(p => p.IpAddress).HasMaxLength(50);
entity.Property(p => p.Culture).HasMaxLength(10);
entity.Property(p => p.ShortUrl).HasMaxLength(255);
entity.Property(p => p.Thread).HasMaxLength(255);
entity.Property(p => p.LogLevel).HasMaxLength(20);
entity.Property(p => p.Logger).HasMaxLength(255);
});
}
}
}