Owneat Technical Guide main Help

Class OrderingContext

Namespace: Ordering.Infrastructure.Persistence
Assembly: Ordering.Infrastructure.dll

public sealed class OrderingContext : DbContext, IInfrastructure<IServiceProvider>, IDbContextDependencies, IDbSetCache, IDbContextPoolable, IResettableService, IDisposable, IAsyncDisposable

Inheritance

objectDbContext ← OrderingContext

Implements

IInfrastructure<IServiceProvider\>, IDbContextDependencies, IDbSetCache, IDbContextPoolable, IResettableService, IDisposable, IAsyncDisposable

Inherited Members

DbContext.Set<TEntity\>\(\), DbContext.Set<TEntity\>\(string\), DbContext.SaveChanges\(\), DbContext.SaveChanges\(bool\), DbContext.SaveChangesAsync\(CancellationToken\), DbContext.SaveChangesAsync\(bool, CancellationToken\), DbContext.Dispose\(\), DbContext.DisposeAsync\(\), DbContext.Entry<TEntity\>\(TEntity\), DbContext.Entry\(object\), DbContext.Add<TEntity\>\(TEntity\), DbContext.AddAsync<TEntity\>\(TEntity, CancellationToken\), DbContext.Attach<TEntity\>\(TEntity\), DbContext.Update<TEntity\>\(TEntity\), DbContext.Remove<TEntity\>\(TEntity\), DbContext.Add\(object\), DbContext.AddAsync\(object, CancellationToken\), DbContext.Attach\(object\), DbContext.Update\(object\), DbContext.Remove\(object\), DbContext.AddRange\(params object\[\]\), DbContext.AddRangeAsync\(params object\[\]\), DbContext.AttachRange\(params object\[\]\), DbContext.UpdateRange\(params object\[\]\), DbContext.RemoveRange\(params object\[\]\), DbContext.AddRange\(IEnumerable<object\>\), DbContext.AddRangeAsync\(IEnumerable<object\>, CancellationToken\), DbContext.AttachRange\(IEnumerable<object\>\), DbContext.UpdateRange\(IEnumerable<object\>\), DbContext.RemoveRange\(IEnumerable<object\>\), DbContext.Find\(Type, params object?\[\]?\), DbContext.FindAsync\(Type, params object?\[\]?\), DbContext.FindAsync\(Type, object?\[\]?, CancellationToken\), DbContext.Find<TEntity\>\(params object?\[\]?\), DbContext.FindAsync<TEntity\>\(params object?\[\]?\), DbContext.FindAsync<TEntity\>\(object?\[\]?, CancellationToken\), DbContext.FromExpression<TResult\>\(Expression<Func<IQueryable<TResult\>\>\>\), DbContext.Database, DbContext.ChangeTracker, DbContext.Model, DbContext.ContextId, DbContext.SavingChanges, DbContext.SavedChanges, DbContext.SaveChangesFailed, object.Equals\(object?\), object.Equals\(object?, object?\), object.GetHashCode\(\), object.GetType\(\), object.ReferenceEquals\(object?, object?\), object.ToString\(\)

Constructors

OrderingContext\(DbContextOptions<OrderingContext\>, IOptions<ConnectionStrings\>\)

public OrderingContext(DbContextOptions<OrderingContext> options, IOptions<ConnectionStrings> connectionStringsOptions)

Parameters

options DbContextOptions < OrderingContext \>

connectionStringsOptions IOptions < ConnectionStrings \>

Properties

Customers

public DbSet<Customer> Customers { get; init; }

Property Value

DbSet <Customer\>

Orders

public DbSet<Order> Orders { get; init; }

Property Value

DbSet <Order\>

Tables

public DbSet<Table> Tables { get; init; }

Property Value

DbSet <Table\>

Methods

OnConfiguring\(DbContextOptionsBuilder\)

Override this method to configure the database (and other options) to be used for this context. This method is called for each instance of the context that is created. The base implementation does nothing.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

Parameters

optionsBuilder DbContextOptionsBuilder

A builder used to create or modify options for this context. Databases (and other extensions) typically define extension methods on this object that allow you to configure the context.

Remarks

In situations where an instance of Microsoft.EntityFrameworkCore.DbContextOptions may or may not have been passed to the constructor, you can use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.IsConfigured to determine if the options have already been set, and skip some or all of the logic in Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder).

See DbContext lifetime, configuration, and initialization for more information and examples.

OnModelCreating\(ModelBuilder\)

Override this method to further configure the model that was discovered by convention from the entity types exposed in Microsoft.EntityFrameworkCore.DbSet%601 properties on your derived context. The resulting model may be cached and re-used for subsequent instances of your derived context.

protected override void OnModelCreating(ModelBuilder modelBuilder)

Parameters

modelBuilder ModelBuilder

The builder being used to construct the model for this context. Databases (and other extensions) typically define extension methods on this object that allow you to configure aspects of the model that are specific to a given database.

Remarks

If a model is explicitly set on the options for this context (via Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.UseModel(Microsoft.EntityFrameworkCore.Metadata.IModel)) then this method will not be run. However, it will still run when creating a compiled model.

See Modeling entity types and relationships for more information and examples.

Last modified: 21 May 2024