diff --git a/entity-framework/core/get-started/winforms.md b/entity-framework/core/get-started/winforms.md index 3e339dbada..e9f5f551dc 100644 --- a/entity-framework/core/get-started/winforms.md +++ b/entity-framework/core/get-started/winforms.md @@ -19,7 +19,7 @@ The screen shots and code listings in this walkthrough are taken from Visual Stu You need to have Visual Studio 2022 17.3 or later installed with the **.NET desktop workload** selected to complete this walkthrough. For more information about installing the latest version of Visual Studio, see [Install Visual Studio](/visualstudio/install/install-visual-studio). -## Create the Application +## Create the application 1. Open Visual Studio 2. On the start window, choose **Create new project**. @@ -48,7 +48,7 @@ You need to have Visual Studio 2022 17.3 or later installed with the **.NET desk > [!NOTE] > The **Microsoft.EntityFrameworkCore.Sqlite** is the "database provider" package for using EF Core with a SQLite database. Similar packages are available for other database systems. Installing a database provider package automatically brings in all the dependencies needed to use EF Core with that database system. This includes the **Microsoft.EntityFrameworkCore** base package. -## Define a Model +## Define a model In this walkthrough we will implement a model using "Code First". This means that EF Core will create the database tables and schema based on the C# classes you define. See [Managing Database Schemas](xref:core/managing-schemas/index) to see how to use an existing database instead. diff --git a/entity-framework/core/get-started/wpf.md b/entity-framework/core/get-started/wpf.md index 9b5c5ffa26..cd25e2b6ce 100644 --- a/entity-framework/core/get-started/wpf.md +++ b/entity-framework/core/get-started/wpf.md @@ -17,11 +17,11 @@ The screen shots and code listings in this walkthrough are taken from Visual Stu > [!TIP] > You can view this article's [sample on GitHub](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/WPF). -## Pre-Requisites +## Pre-requisites You need to have Visual Studio 2019 16.3 or later installed with the **.NET desktop workload** selected to complete this walkthrough. For more information about installing the latest version of Visual Studio, see [Install Visual Studio](/visualstudio/install/install-visual-studio). -## Create the Application +## Create the application 1. Open Visual Studio 2. On the start window, choose **Create new project**. @@ -45,7 +45,7 @@ You need to have Visual Studio 2019 16.3 or later installed with the **.NET desk > [!NOTE] > When you installed the Sqlite package, it automatically pulled down the related **Microsoft.EntityFrameworkCore** base package. The **Microsoft.EntityFrameworkCore.Proxies** package provides support for "lazy-loading" data. This means when you have entities with child entities, only the parents are fetched on the initial load. The proxies detect when an attempt to access the child entities is made and automatically loads them on demand. -## Define a Model +## Define a model In this walkthrough you will implement a model using "code first." This means that EF Core will create the database tables and schema based on the C# classes you define. @@ -83,7 +83,7 @@ Press **CTRL+SHIFT+B** or navigate to **Build > Build Solution** to compile t > [!TIP] > 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 +## Lazy loading The **Products** property on the **Category** class and **Category** property on the **Product** class are navigation properties. In Entity Framework Core, navigation properties provide a way to navigate a relationship between two entity types. @@ -91,7 +91,7 @@ EF Core gives you an option of loading related entities from the database automa When using "Plain Old C# Object" (POCO) entity types, EF Core achieves lazy loading by creating instances of derived proxy types during runtime and then overriding virtual properties in your classes to add the loading hook. To get lazy loading of related objects, you must declare navigation property getters as **public** and **virtual** (**Overridable** in Visual Basic), and your class must not be **sealed** (**NotOverridable** in Visual Basic). When using Database First, navigation properties are automatically made virtual to enable lazy loading. -## Bind Object to Controls +## Bind object to controls Add the classes that are defined in the model as data sources for this WPF application. @@ -108,7 +108,7 @@ Add the classes that are defined in the model as data sources for this WPF appli 1. Note that the `CategoryId` is set to `ReadOnly` because it is assigned by the database and cannot be changed. -## Adding a Details Grid +## Adding a details grid Now that the grid exists to display categories, the details grid can be added to show products. Add this inside the `Grid` element, after the categories `DataGrid` element. @@ -125,7 +125,7 @@ Your design view should look like this: ![Screenshot of WPF Designer](_static/wpf-tutorial-designer.jpg) -## Add Code that Handles Data Interaction +## Add code that handles data interaction It's time to add some event handlers to the main window. @@ -145,13 +145,13 @@ The code declares a long-running instance of `ProductContext`. The `ProductConte > [!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](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 +## Test the WPF application Compile and run the application by pressing **F5** or choosing **Debug > Start Debugging**. The database should be automatically created with a file named `products.db`. Enter a category name and hit enter, then add products to the lower grid. Click save and watch the grid refresh with the database provided ids. Highlight a row and hit **Delete** to remove the row. The entity will be deleted when you click **Save**. ![Running application](_static/wpf-tutorial-app.jpg) -## Property Change Notification +## Property change notification This example relies on four steps to synchronize the entities with the UI. @@ -165,6 +165,6 @@ This works for our getting started sample, but you may require additional code f > [!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 +## Next steps Learn more about [Configuring a DbContext](xref:core/dbcontext-configuration/index). diff --git a/entity-framework/core/modeling/bulk-configuration.md b/entity-framework/core/modeling/bulk-configuration.md index 56bf6ff4e0..c83fff0524 100644 --- a/entity-framework/core/modeling/bulk-configuration.md +++ b/entity-framework/core/modeling/bulk-configuration.md @@ -25,7 +25,7 @@ Properties of this type are not discovered by default as the current EF provider [!code-csharp[Main](../../../samples/core/Modeling/BulkConfiguration/CurrencyConverter.cs?name=CurrencyConverter)] -### Drawbacks of the Metadata API +### Drawbacks of the metadata API - Unlike [Fluent API](xref:core/modeling/index#use-fluent-api-to-configure-a-model), every modification to the model needs to be done explicitly. For example, if some of the `Currency` properties were configured as navigations by a convention then you need to first remove the navigation referencing the CLR property before adding an entity type property for it. [#9117](https://github.com/dotnet/efcore/issues/9117) will improve this. - The conventions run after each change. If you remove a navigation discovered by a convention then the convention will run again and could add it back. To prevent this from happening you would need to either delay the conventions until after the property is added by calling and later disposing the returned object or to mark the CLR property as ignored using . diff --git a/entity-framework/core/modeling/entity-properties.md b/entity-framework/core/modeling/entity-properties.md index 3f378076b7..9db50d1c8f 100644 --- a/entity-framework/core/modeling/entity-properties.md +++ b/entity-framework/core/modeling/entity-properties.md @@ -78,7 +78,7 @@ In the following example, configuring a maximum length of 500 will cause a colum *** -### Precision and Scale +### Precision and scale Some relational data types support the precision and scale facets; these control what values can be stored, and how much storage is needed for the column. Which data types support precision and scale is database-dependent, but in most databases `decimal` and `DateTime` types do support these facets. For `decimal` properties, precision defines the maximum number of digits needed to express any value the column will contain, and scale defines the maximum number of decimal places needed. For `DateTime` properties, precision defines the maximum number of digits needed to express fractions of seconds, and scale is not used. diff --git a/entity-framework/core/modeling/keyless-entity-types.md b/entity-framework/core/modeling/keyless-entity-types.md index f1c22e0799..627d49b2fa 100644 --- a/entity-framework/core/modeling/keyless-entity-types.md +++ b/entity-framework/core/modeling/keyless-entity-types.md @@ -12,7 +12,7 @@ uid: core/modeling/keyless-entity-types In addition to regular entity types, an EF Core model can contain _keyless entity types_, which can be used to carry out database queries against data that doesn't contain key values. -## Defining Keyless entity types +## Defining keyless entity types Keyless entity types can be defined as follows: diff --git a/entity-framework/core/modeling/keys.md b/entity-framework/core/modeling/keys.md index bbb8ef5bec..50c27ac7c2 100644 --- a/entity-framework/core/modeling/keys.md +++ b/entity-framework/core/modeling/keys.md @@ -72,7 +72,7 @@ Key properties must always have a non-default value when adding a new entity to > [!IMPORTANT] > If a key property has its value generated by the database and a non-default value is specified when an entity is added, then EF will assume that the entity already exists in the database and will try to update it instead of inserting a new one. To avoid this, turn off value generation or see [how to specify explicit values for generated properties](xref:core/modeling/generated-properties#overriding-value-generation). -## Alternate Keys +## Alternate keys An alternate key serves as an alternate unique identifier for each entity instance in addition to the primary key; it can be used as the target of a relationship. When using a relational database this maps to the concept of a unique index/constraint on the alternate key column(s) and one or more foreign key constraints that reference the column(s). diff --git a/entity-framework/core/modeling/spatial.md b/entity-framework/core/modeling/spatial.md index a8a484e7e4..c8a09a55f0 100644 --- a/entity-framework/core/modeling/spatial.md +++ b/entity-framework/core/modeling/spatial.md @@ -52,11 +52,11 @@ There are several spatial data types. Which type you use depends on the types of Using the base Geometry type allows any type of shape to be specified by the property. -## Longitude and Latitude +## Longitude and latitude Coordinates in NTS are in terms of X and Y values. To represent longitude and latitude, use X for longitude and Y for latitude. Note that this is **backwards** from the `latitude, longitude` format in which you typically see these values. -## Querying Data +## Querying data The following entity classes could be used to map to tables in the [Wide World Importers sample database](https://go.microsoft.com/fwlink/?LinkID=800630). @@ -74,7 +74,7 @@ In LINQ, the NTS methods and properties available as database functions will be The spatial NuGet packages also enable [reverse engineering](xref:core/managing-schemas/scaffolding) models with spatial properties, but you need to install the package ***before*** running `Scaffold-DbContext` or `dotnet ef dbcontext scaffold`. If you don't, you'll receive warnings about not finding type mappings for the columns and the columns will be skipped. -## SRID Ignored during client operations +## SRID ignored during client operations NTS ignores SRID values during operations. It assumes a planar coordinate system. This means that if you specify coordinates in terms of longitude and latitude, some client-evaluated values like distance, length, and area will be in degrees, not meters. For more meaningful values, you first need to project the coordinates to another coordinate system using a library like [ProjNet (for GeoAPI)](https://github.com/NetTopologySuite/ProjNet4GeoAPI). diff --git a/entity-framework/core/querying/complex-query-operators.md b/entity-framework/core/querying/complex-query-operators.md index 50309c4a6c..ecfb3a6377 100644 --- a/entity-framework/core/querying/complex-query-operators.md +++ b/entity-framework/core/querying/complex-query-operators.md @@ -141,7 +141,7 @@ ORDER BY [b].[Price] In this case, the GroupBy operator doesn't translate directly to a `GROUP BY` clause in the SQL, but instead, EF Core creates the groupings after the results are returned from the server. -## Left Join +## Left join While Left Join isn't a LINQ operator, relational databases have the concept of a Left Join which is frequently used in queries. A particular pattern in LINQ queries gives the same result as a `LEFT JOIN` on the server. EF Core identifies such patterns and generates the equivalent `LEFT JOIN` on the server side. The pattern involves creating a GroupJoin between both the data sources and then flattening out the grouping by using the SelectMany operator with DefaultIfEmpty on the grouping source to match null when the inner doesn't have a related element. The following example shows what that pattern looks like and what it generates. diff --git a/entity-framework/core/querying/sql-queries.md b/entity-framework/core/querying/sql-queries.md index c30f503e5f..a44aea05fe 100644 --- a/entity-framework/core/querying/sql-queries.md +++ b/entity-framework/core/querying/sql-queries.md @@ -162,7 +162,7 @@ Composing with LINQ requires your SQL query to be composable, since EF Core will SQL Server doesn't allow composing over stored procedure calls, so any attempt to apply additional query operators to such a call will result in invalid SQL. Use or right after or to make sure that EF Core doesn't try to compose over a stored procedure. -## Change Tracking +## Change tracking Queries that use or follow the exact same change tracking rules as any other LINQ query in EF Core. For example, if the query projects entity types, the results are tracked by default. diff --git a/entity-framework/core/saving/basic.md b/entity-framework/core/saving/basic.md index ec972e066d..972ecbb9f8 100644 --- a/entity-framework/core/saving/basic.md +++ b/entity-framework/core/saving/basic.md @@ -37,7 +37,7 @@ Use the