|
2 | 2 | title: What's New in EF Core 5.0
|
3 | 3 | description: Overview of new features in EF Core 5.0
|
4 | 4 | author: ajcvickers
|
5 |
| -ms.date: 03/15/2020 |
| 5 | +ms.date: 03/30/2020 |
6 | 6 | uid: core/what-is-new/ef-core-5.0/whatsnew.md
|
7 | 7 | ---
|
8 | 8 |
|
@@ -189,3 +189,59 @@ Documentation is tracked by issue [#2079](https://github.com/dotnet/EntityFramew
|
189 | 189 | Queries that use the string methods Contains, StartsWith, and EndsWith are now translated when using the Azure Cosmos DB provider.
|
190 | 190 |
|
191 | 191 | Documentation is tracked by issue [#2079](https://github.com/dotnet/EntityFramework.Docs/issues/2079).
|
| 192 | + |
| 193 | +## Preview 2 |
| 194 | + |
| 195 | +### Use a C# attribute to specify a property backing field |
| 196 | + |
| 197 | +A C# attribute can now be used to specify the backing field for a property. |
| 198 | +This allows EF Core to still write to and read from the backing field as would normally happen, even when the backing field cannot be found automatically. |
| 199 | +For example: |
| 200 | + |
| 201 | +```CSharp |
| 202 | +public class Blog |
| 203 | +{ |
| 204 | + private string _mainTitle; |
| 205 | + |
| 206 | + public int Id { get; set; } |
| 207 | + |
| 208 | + [BackingField(nameof(_mainTitle))] |
| 209 | + public string Title |
| 210 | + { |
| 211 | + get => _mainTitle; |
| 212 | + set => _mainTitle = value; |
| 213 | + } |
| 214 | +} |
| 215 | +``` |
| 216 | + |
| 217 | +Documentation is tracked by issue [#2230](https://github.com/dotnet/EntityFramework.Docs/issues/2230). |
| 218 | + |
| 219 | +### Complete discriminator mapping |
| 220 | + |
| 221 | +EF Core uses a discriminator column for [TPH mapping of an inheritance hierarchy](/ef/core/modeling/inheritance). |
| 222 | +Some performance enhancements are possible so long as EF Core knows all possible values for the discriminator. |
| 223 | +EF Core 5.0 now implements these enhancements. |
| 224 | + |
| 225 | +For example, previous versions of EF Core would always generate this SQL for a query returning all types in a hierarchy: |
| 226 | + |
| 227 | +```sql |
| 228 | +SELECT [a].[Id], [a].[Discriminator], [a].[Name] |
| 229 | +FROM [Animal] AS [a] |
| 230 | +WHERE [a].[Discriminator] IN (N'Animal', N'Cat', N'Dog', N'Human') |
| 231 | +``` |
| 232 | + |
| 233 | +EF Core 5.0 will now generate the following when a complete discriminator mapping is configured: |
| 234 | +```sql |
| 235 | +SELECT [a].[Id], [a].[Discriminator], [a].[Name] |
| 236 | +FROM [Animal] AS [a] |
| 237 | +``` |
| 238 | + |
| 239 | +This will be the default behavior starting with preview 3. |
| 240 | + |
| 241 | +### Performance improvements in Microsoft.Data.Sqlite |
| 242 | + |
| 243 | +We have made two performance improvements for SQLIte: |
| 244 | +* Retrieving binary and string data with GetBytes, GetChars, and GetTextReader is now more efficient by making use of SqliteBlob and streams. |
| 245 | +* Initialization of SqliteConnection is now lazy. |
| 246 | + |
| 247 | +These improvements are in the ADO.NET Microsoft.Data.Sqlite provider and hence also improve performance outside of EF Core. |
0 commit comments