1

I am creating a site in C# with Entity Framework 5 and Code-first Migrations for the Database Integration. I am not very experienced with either of these nor MSSQL and am looking to build a log table (which I can manage fine).

The Issue I am having is that I don't know whether MSSQL or the Entity Framework has support for restricted size tables (1000 rows for example). Below is the Log functionality as I have it right now. If anyone knows of an existing question which asks the same thing, please link it as I didn't find any in my search.

public enum LogLevel
{
    INFO,
    WARNING,
    ERROR,
    CRITICAL
}
public class Logger
{
    private static LogContext db = new LogContext();
    public static void Log(LogLevel severity, String logData)
    {
        if (db == null) db = new LogContext(); //Just to make sure
        db.Logs.Add(new Log
        {
            Severity = severity,
            Data = logData
        });
        db.SaveChanges();
    }
}

public class LogContext : DbContext
{
    public LogContext() : base("DefaultConnection")
    {
    }

    public DbSet<Log> Logs { get; set; }
}

public class Log
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public long Id { get; set; }
    public LogLevel Severity { get; set; }
    public String Data { get; set; }
}

-Nicka101

nicka101
  • 21
  • 1
  • 5

0 Answers0