Skip to end of metadata
Go to start of metadata

Represents the entity context for entity framework logging.

Definition

public class LogContext : DbContext

Summary

The following table summarizes the members exposed in this class.

Public Constructors

LogContext Constructor(string) Initializes a new instance of the LogContext class.
LogContext Constructor(string, string) Initializes a new instance of the LogContext class.

Public Properties

Logs Gets or sets the logs.
TableName Gets the name of the table.

Protected Methods

OnModelCreating(DbModelBuilder) This method is called when the model for a derived context has been initialized, but before the model has been locked down and used to initialize the context. The default implementation of this method does nothing, but it can be overridden in a derived class such that the model can be further configured before it is locked down.

Public Constructors

public LogContext(string nameOrConnectionString)

Initializes a new instance of the LogContext class.

Parameters

nameOrConnectionString Either the database name or a connection string.

public LogContext(string nameOrConnectionString, string tableName)

Initializes a new instance of the LogContext class.

Parameters

nameOrConnectionString The name or connection string.
tableName Name of the table.

Public Properties

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

Gets or sets the logs.

public string TableName { get; }

Gets the name of the table.

Protected Methods

protected void OnModelCreating(DbModelBuilder modelBuilder)

This method is called when the model for a derived context has been initialized, but before the model has been locked down and used to initialize the context. The default implementation of this method does nothing, but it can be overridden in a derived class such that the model can be further configured before it is locked down.

Remarks

Typically, this method is called only once when the first instance of a derived context is created. The model for that context is then cached and is for all further instances of the context in the app domain. This caching can be disabled by setting the ModelCaching property on the given ModelBuidler, but note that this can seriously degrade performance. More control over caching is provided through use of the DbModelBuilder and DbContextFactory classes directly.

Parameters

modelBuilder The builder that defines the model for the context being created.
  • No labels