Skip to content

Commit

Permalink
Day 36 - Log & LogMap Classes Adding
Browse files Browse the repository at this point in the history
  • Loading branch information
fdeniz07 committed Nov 3, 2021
1 parent 195214b commit 54831f6
Show file tree
Hide file tree
Showing 6 changed files with 1,904 additions and 101 deletions.
37 changes: 37 additions & 0 deletions DataAccessLayer/Concrete/Configurations/LogMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using EntityLayer.Concrete;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace DataAccessLayer.Concrete.Configurations
{
public class LogMap:IEntityTypeConfiguration<Log>
{
public void Configure(EntityTypeBuilder<Log> builder)
{
builder.HasKey(l => l.Id);
builder.Property(l => l.Id).ValueGeneratedOnAdd();

builder.Property(l => l.MachineName).IsRequired();
builder.Property(l => l.MachineName).HasMaxLength(50);

builder.Property(l => l.Logged).IsRequired();

builder.Property(l => l.Level).IsRequired();
builder.Property(l => l.Level).HasMaxLength(50);

builder.Property(l => l.Message).IsRequired();
builder.Property(l => l.Message).HasColumnType("NVARCHAR(MAX)");

builder.Property(l => l.Logger).IsRequired(false);
builder.Property(l => l.Logger).HasMaxLength(250);

builder.Property(l => l.Callsite).IsRequired(false);
builder.Property(l => l.Callsite).HasColumnType("NVARCHAR(MAX)");

builder.Property(l => l.Exception).IsRequired(false);
builder.Property(l => l.Exception).HasColumnType("NVARCHAR(MAX)");

builder.ToTable("Logs");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public class MsDbContext : IdentityDbContext<User,Role,int,UserClaim,UserRole,Us
public DbSet<Category> Categories { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<Contact> Contacts { get; set; }


public DbSet<Log> Logs { get; set; }
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//{
// optionsBuilder.UseSqlServer(
Expand Down Expand Up @@ -42,6 +41,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.ApplyConfiguration(new UserLoginMap());
modelBuilder.ApplyConfiguration(new UserRoleMap());
modelBuilder.ApplyConfiguration(new UserTokenMap());
modelBuilder.ApplyConfiguration(new LogMap());
}
}
}
Loading

0 comments on commit 54831f6

Please sign in to comment.