Add debug output

This commit is contained in:
Arti Zirk 2017-03-01 17:36:22 +02:00
parent ae16f6f7ce
commit 74a391db4f

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Entity; using System.Data.Entity;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,6 +15,20 @@ namespace DAL
public AppDbContext() : base(nameOrConnectionString: "name=AppDbConnectionString") public AppDbContext() : base(nameOrConnectionString: "name=AppDbConnectionString")
{ {
Database.SetInitializer(new DbInit()); Database.SetInitializer(new DbInit());
Database.Log = s =>
{
if (s.Contains("SELECT"))
{
#if DEBUG
Trace.Write(s);
#else
Console.WriteLine(s);
#endif
}
};
} }
public DbSet<Person> People { get; set; } public DbSet<Person> People { get; set; }