Update README.
This commit is contained in:
parent
915434f44d
commit
29aebcea18
21
README.md
21
README.md
@ -81,3 +81,24 @@ Note that the [Microsoft.EntityFrameworkCore.Tools](https://www.nuget.org/packag
|
||||
[Microsoft.EntityFrameworkCore.Sqlite](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite/9.0.3)
|
||||
|
||||
* `dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 9.0.3`
|
||||
|
||||
## Tips for efficient querying
|
||||
|
||||
* Use indexes.
|
||||
* Use projections.
|
||||
* Limit result set (skip and take)
|
||||
* Use async calls.
|
||||
* Use `FromSQLRaw()` for an optimized query if it gets complex in LINQ.
|
||||
* Use no-tracking.
|
||||
* Use batch operations.
|
||||
|
||||
### Tracking
|
||||
|
||||
Tracking works best when the same DbContext is used for both querying and changing entities. EF Core automatically tracks the state of the queried entities and detects any changes made, until `SaveChanges()` is called, which is a method to save pending changes to the database. These changes are detected with the `DetectChanges()` function. This function can be manually called, to see what the changes are, but it is automatically called by the `SaveChanges()` function. `SaveChanges()` is transactional (for most providers).
|
||||
|
||||
The following states are tracked in the `EntityState.State` property:
|
||||
* **Detached**: entity is not tracked.
|
||||
* **Added**: new entity, not yet added to the database.
|
||||
* **Unchanged**: no changes to the entity.
|
||||
* **Modified**: changes are made to the entity.
|
||||
* **Deleted**: the entity is in the database, but is marked for deletion.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user