Документация
This commit is contained in:
@@ -3,11 +3,39 @@
|
||||
|
||||
## AbstractEntityProcessor\.Context Property
|
||||
|
||||
Предоставляет механизм для освобождения неуправляемых ресурсов\.
|
||||
A DbContext instance represents a session with the database and can be used to query and save
|
||||
instances of your entities\. DbContext is a combination of the Unit Of Work and Repository patterns\.
|
||||
|
||||
```csharp
|
||||
public Pf2e.Database.Pf2eDbContext Context { get; }
|
||||
```
|
||||
|
||||
#### Property Value
|
||||
[Pf2e\.Database\.Pf2eDbContext](https://docs.microsoft.com/en-us/dotnet/api/Pf2e.Database.Pf2eDbContext 'Pf2e\.Database\.Pf2eDbContext')
|
||||
[Pf2e\.Database\.Pf2eDbContext](https://learn.microsoft.com/en-us/dotnet/api/pf2e.database.pf2edbcontext 'Pf2e\.Database\.Pf2eDbContext')
|
||||
|
||||
### Remarks
|
||||
|
||||
Entity Framework Core does not support multiple parallel operations being run on the same DbContext instance. This
|
||||
includes both parallel execution of async queries and any explicit concurrent use from multiple threads.
|
||||
Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute
|
||||
in parallel. See [Avoiding DbContext threading issues](https://aka.ms/efcore-docs-threading 'https://aka\.ms/efcore\-docs\-threading') for more information
|
||||
and examples.
|
||||
|
||||
Typically you create a class that derives from DbContext and contains [Microsoft\.EntityFrameworkCore\.DbSet<>](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbset-1 'Microsoft\.EntityFrameworkCore\.DbSet\`1')
|
||||
properties for each entity in the model. If the [Microsoft\.EntityFrameworkCore\.DbSet<>](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbset-1 'Microsoft\.EntityFrameworkCore\.DbSet\`1') properties have a public setter,
|
||||
they are automatically initialized when the instance of the derived context is created.
|
||||
|
||||
Override the [Microsoft\.EntityFrameworkCore\.DbContext\.OnConfiguring\(Microsoft\.EntityFrameworkCore\.DbContextOptionsBuilder\)](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontext.onconfiguring#microsoft-entityframeworkcore-dbcontext-onconfiguring(microsoft-entityframeworkcore-dbcontextoptionsbuilder) 'Microsoft\.EntityFrameworkCore\.DbContext\.OnConfiguring\(Microsoft\.EntityFrameworkCore\.DbContextOptionsBuilder\)') method to configure the database (and
|
||||
other options) to be used for the context. Alternatively, if you would rather perform configuration externally
|
||||
instead of inline in your context, you can use [Microsoft\.EntityFrameworkCore\.DbContextOptionsBuilder<>](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptionsbuilder-1 'Microsoft\.EntityFrameworkCore\.DbContextOptionsBuilder\`1')
|
||||
(or [Microsoft\.EntityFrameworkCore\.DbContextOptionsBuilder](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptionsbuilder 'Microsoft\.EntityFrameworkCore\.DbContextOptionsBuilder')) to externally create an instance of [Microsoft\.EntityFrameworkCore\.DbContextOptions<>](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptions-1 'Microsoft\.EntityFrameworkCore\.DbContextOptions\`1')
|
||||
(or [Microsoft\.EntityFrameworkCore\.DbContextOptions](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptions 'Microsoft\.EntityFrameworkCore\.DbContextOptions')) and pass it to a base constructor of [Microsoft\.EntityFrameworkCore\.DbContext](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontext 'Microsoft\.EntityFrameworkCore\.DbContext').
|
||||
|
||||
The model is discovered by running a set of conventions over the entity classes found in the
|
||||
[Microsoft\.EntityFrameworkCore\.DbSet<>](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbset-1 'Microsoft\.EntityFrameworkCore\.DbSet\`1') properties on the derived context. To further configure the model that
|
||||
is discovered by convention, you can override the [Microsoft\.EntityFrameworkCore\.DbContext\.OnModelCreating\(Microsoft\.EntityFrameworkCore\.ModelBuilder\)](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontext.onmodelcreating#microsoft-entityframeworkcore-dbcontext-onmodelcreating(microsoft-entityframeworkcore-modelbuilder) 'Microsoft\.EntityFrameworkCore\.DbContext\.OnModelCreating\(Microsoft\.EntityFrameworkCore\.ModelBuilder\)') method.
|
||||
|
||||
See [DbContext lifetime, configuration, and initialization](https://aka.ms/efcore-docs-dbcontext 'https://aka\.ms/efcore\-docs\-dbcontext'),
|
||||
[Querying data with EF Core](https://aka.ms/efcore-docs-query 'https://aka\.ms/efcore\-docs\-query'),
|
||||
[Changing tracking](https://aka.ms/efcore-docs-change-tracking 'https://aka\.ms/efcore\-docs\-change\-tracking'), and
|
||||
[Saving data with EF Core](https://aka.ms/efcore-docs-saving-data 'https://aka\.ms/efcore\-docs\-saving\-data') for more information and examples.
|
||||
Reference in New Issue
Block a user