Skip to content

Commit

Permalink
Clean up links (part 1) (#2603)
Browse files Browse the repository at this point in the history
Part of #2447
  • Loading branch information
smitpatel committed Sep 2, 2020
1 parent b76af2b commit 98e132b
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 96 deletions.
12 changes: 6 additions & 6 deletions entity-framework/core/get-started/wpf.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ Add a new `ProductContext.cs` class to the project with the following definition
[!code-csharp[](../../../samples/core/WPF/GetStartedWPF/GetStartedWPF/ProductContext.cs)]

* The `DbSet` informs EF Core what C# entities should be mapped to the database.
* There are a variety of ways to configure the EF Core `DbContext`. You can read about them in: [Configuring a DbContext](/ef/core/miscellaneous/configuring-dbcontext).
* There are a variety of ways to configure the EF Core `DbContext`. You can read about them in: [Configuring a DbContext](xref:core/miscellaneous/configuring-dbcontext).
* This example uses the `OnConfiguring` override to specify a Sqlite data file.
* The `UseLazyLoadingProxies` call tells EF Core to implement lazy-loading, so child entities are automatically loaded when accessed from the parent.

Press **CTRL+SHIFT+B** or navigate to **Build > Build Solution** to compile the project.

> [!TIP]
> Learn about the different was to keep your database and EF Core models in sync: [Managing Database Schemas](/ef/core/managing-schemas).
> Learn about the different was to keep your database and EF Core models in sync: [Managing Database Schemas](xref:core/managing-schemas/index).
## Lazy Loading

Expand Down Expand Up @@ -143,7 +143,7 @@ The code declares a long-running instance of `ProductContext`. The `ProductConte
[!code-csharp[](../../../samples/core/WPF/GetStartedWPF/GetStartedWPF/MainWindow.xaml.cs)]

> [!NOTE]
> The code uses a call to `EnsureCreated()` to build the database on the first run. This is acceptable for demos, but in production apps you should look at [migrations](/ef/core/managing-schemas/migrations/) to manage your schema. The code also executes synchronously because it uses a local SQLite database. For production scenarios that typically involve a remote server, consider using the asynchronous versions of the `Load` and `SaveChanges` methods.
> The code uses a call to `EnsureCreated()` to build the database on the first run. This is acceptable for demos, but in production apps you should look at [migrations](xref:core/managing-schemas/migrations/index) to manage your schema. The code also executes synchronously because it uses a local SQLite database. For production scenarios that typically involve a remote server, consider using the asynchronous versions of the `Load` and `SaveChanges` methods.
## Test the WPF Application

Expand All @@ -153,18 +153,18 @@ Compile and run the application by pressing **F5** or choosing **Debug > Star

## Property Change Notification

This example relies on four steps to synchronize the entities with the UI.
This example relies on four steps to synchronize the entities with the UI.

1. The initial call `_context.Categories.Load()` loads the categories data.
1. The lazy-loading proxies load the dependent products data.
1. EF Core's built-in change tracking makes the necessary modifications to entities, including insertions and deletions, when `_context.SaveChanges()` is called.
1. The calls to `DataGridView.Items.Refresh()` force a reload with the newly generated ids.

This works for our getting started sample, but you may require additional code for other scenarios. WPF controls render the UI by reading the fields and properties on your entities. When you edit a value in the user interface (UI), that value is passed to your entity. When you change the value of a property directly on your entity, such as loading it from the database, WPF will not immediately reflect the changes in the UI. The rendering engine must be notified of the changes. The project did this by manually calling `Refresh()`. An easy way to automate this notification is by implementing the [INotifyPropertyChanged](/dotnet/api/system.componentmodel.inotifypropertychanged) interface. WPF components will automatically detect the interface and register for change events. The entity is responsible for raising these events.
This works for our getting started sample, but you may require additional code for other scenarios. WPF controls render the UI by reading the fields and properties on your entities. When you edit a value in the user interface (UI), that value is passed to your entity. When you change the value of a property directly on your entity, such as loading it from the database, WPF will not immediately reflect the changes in the UI. The rendering engine must be notified of the changes. The project did this by manually calling `Refresh()`. An easy way to automate this notification is by implementing the [INotifyPropertyChanged](/dotnet/api/system.componentmodel.inotifypropertychanged) interface. WPF components will automatically detect the interface and register for change events. The entity is responsible for raising these events.

> [!TIP]
> To learn more about how to handle changes, read: [How to implement property change notification](/dotnet/framework/wpf/data/how-to-implement-property-change-notification).
## Next Steps

Learn more about [Configuring a DbContext](/ef/core/miscellaneous/configuring-dbcontext).
Learn more about [Configuring a DbContext](xref:core/miscellaneous/configuring-dbcontext).
2 changes: 1 addition & 1 deletion entity-framework/core/managing-schemas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Managing Database Schemas - EF Core
author: bricelam
ms.date: 10/30/2017
uid: core/managing-schemas/index
---
# Managing Database Schemas

Expand All @@ -19,7 +20,6 @@ scaffold a DbContext and the entity type classes by reverse engineering your dat
> The [create and drop APIs][3] can also create the database schema from your EF Core model. However, they are primarily
> for testing, prototyping, and other scenarios where dropping the database is acceptable.

[1]: migrations/index.md
[2]: scaffolding.md
[3]: ensure-created.md
10 changes: 6 additions & 4 deletions entity-framework/core/what-is-new/ef-core-5.0/whatsnew.md
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ See the [Configuring Navigation Properties documentation](xref:core/modeling/rel

Migrations and scaffolding now allow namespaces to be specified on the command line. For example, to reverse engineer a database putting the context and model classes in different namespaces:

```
```dotnetcli
dotnet ef dbcontext scaffold "connection string" Microsoft.EntityFrameworkCore.SqlServer --context-namespace "My.Context" --namespace "My.Model"
```

Expand All @@ -976,7 +976,7 @@ See the [Migrations](xref:core/managing-schemas/migrations/index#namespaces) and
---
Also, a connection string can now be passed to the `database-update` command:

```
```dotnetcli
dotnet ef database update --connection "connection string"
```

Expand All @@ -991,6 +991,7 @@ For performance reasons, EF doesn't do additional null-checks when reading value
Using `EnableDetailedErrors` will add extra null checking to queries such that, for a small performance overhead, these errors are easier to trace back to a root cause.

For example:

```CSharp
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
Expand All @@ -1016,6 +1017,7 @@ Documentation is tracked by issue [#2199](https://github.com/dotnet/EntityFramew
### Support for the SQL Server DATALENGTH function

This can be accessed using the new `EF.Functions.DataLength` method. For example:

```CSharp
var count = context.Orders.Count(c => 100 < EF.Functions.DataLength(c.OrderDate));
```
Expand Down Expand Up @@ -1046,7 +1048,7 @@ Documentation is tracked by issue [#2230](https://github.com/dotnet/EntityFramew

### Complete discriminator mapping

EF Core uses a discriminator column for [TPH mapping of an inheritance hierarchy](/ef/core/modeling/inheritance). Some performance enhancements are possible so long as EF Core knows all possible values for the discriminator. EF Core 5.0 now implements these enhancements.
EF Core uses a discriminator column for [TPH mapping of an inheritance hierarchy](xref:core/modeling/inheritance). Some performance enhancements are possible so long as EF Core knows all possible values for the discriminator. EF Core 5.0 now implements these enhancements.

For example, previous versions of EF Core would always generate this SQL for a query returning all types in a hierarchy:

Expand Down Expand Up @@ -1174,7 +1176,7 @@ The Azure Cosmos DB database provider now supports optimistic concurrency using
builder.Entity<Customer>().Property(c => c.ETag).IsEtagConcurrency();
```

SaveChanges will then throw an `DbUpdateConcurrencyException` on a concurrency conflict, which [can be handled](/ef/core/saving/concurrency) to implement retries, etc.
SaveChanges will then throw an `DbUpdateConcurrencyException` on a concurrency conflict, which [can be handled](xref:core/saving/concurrency) to implement retries, etc.

Documentation is tracked by issue [#2099](https://github.com/dotnet/EntityFramework.Docs/issues/2099).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ ms.date: "10/23/2016"
ms.assetid: 5b1f7a7d-1b24-4645-95ec-5608a31ef577
---
# Handling transaction commit failures

> [!NOTE]
> **EF6.1 Onwards Only** - The features, APIs, etc. discussed in this page were introduced in Entity Framework 6.1. If you are using an earlier version, some or all of the information does not apply.
As part of 6.1 we are introducing a new connection resiliency feature for EF: the ability to detect and recover automatically when transient connection failures affect the acknowledgement of transaction commits. The full details of the scenario are best described in the blog post [SQL Database Connectivity and the Idempotency Issue](https://docs.microsoft.com/archive/blogs/adonet/sql-database-connectivity-and-the-idempotency-issue). In summary, the scenario is that when an exception is raised during a transaction commit there are two possible causes:
As part of 6.1 we are introducing a new connection resiliency feature for EF: the ability to detect and recover automatically when transient connection failures affect the acknowledgement of transaction commits. The full details of the scenario are best described in the blog post [SQL Database Connectivity and the Idempotency Issue](/archive/blogs/adonet/sql-database-connectivity-and-the-idempotency-issue). In summary, the scenario is that when an exception is raised during a transaction commit there are two possible causes:

1. The transaction commit failed on the server
2. The transaction commit succeeded on the server but a connectivity issue prevented the success notification from reaching the client
Expand Down Expand Up @@ -59,8 +60,8 @@ Before EF 6.1 there was not mechanism to handle commit failures in the EF produc
1. Add a non-tracked table to the database used to track the status of the transactions.
2. Insert a row into the table at the beginning of each transaction.
3. If the connection fails during the commit, check for the presence of the corresponding row in the database.
- If the row is present, continue normally, as the transaction was committed successfully
- If the row is absent, use an execution strategy to retry the current operation.
* If the row is present, continue normally, as the transaction was committed successfully
* If the row is absent, use an execution strategy to retry the current operation.
4. If the commit is successful, delete the corresponding row to avoid the growth of the table.

[This blog post](https://docs.microsoft.com/archive/blogs/adonet/sql-database-connectivity-and-the-idempotency-issue) contains sample code for accomplishing this on SQL Azure.
[This blog post](/archive/blogs/adonet/sql-database-connectivity-and-the-idempotency-issue) contains sample code for accomplishing this on SQL Azure.
1 change: 1 addition & 0 deletions entity-framework/ef6/fundamentals/databinding/winforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Databinding with WinForms - EF6"
author: divega
ms.date: "10/23/2016"
ms.assetid: 80fc5062-2f1c-4dbd-ab6e-b99496784b36
uid: ef6/fundamentals/databinding/winforms
---
# Databinding with WinForms
This step-by-step walkthrough shows how to bind POCO types to Window Forms (WinForms) controls in a “master-detail" form. The application uses Entity Framework to populate objects with data from the database, track changes, and persist data to the database.
Expand Down
Loading

0 comments on commit 98e132b

Please sign in to comment.