The .NET Stacks #14: Checking in on NuGet changes, many-to-many in EF Core, community roundup, and more!
We discuss many-to-many in EF Core 5, check in with upcoming NuGet changes, and look at the busy week in the .NET community!
Happy Monday. Do you ever watch a satire and think it’s a documentary?
This week, we’ll:
- Get excited about many-to-many in EF Core
- Take a look at some current and upcoming NuGet changes
- Check in on the community
Many-to-many in EF Core 5
So this is exciting: many-to-many support is now included in the Entity Framework Core daily builds, and the team spent this week’s community standup showing it off.
A big part of this work includes the concept of skip navigations, or many-to-many navigation properties. For example, here’s a basic model that assigns links in a newsletter (what can I say, it’s fresh on my mind) and is a good use case for many-to-many and is … heavily inspired and/or outright stolen from the GitHub issue:
public class Link
{
public int LinkId { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public List<LinkTag> LinkTags { get; set; }
}
public class Tag
{
public string TagId { get; set; }
public string Description { get; set; }
public List<LinkTag> LinkTags { get; set; }
}
public class LinkTag
{
public int LinkId { get; set; }
public Link Link { get; set; }
public string TagId { get; set; }
public Tag Tag { get; set; }
public DateTime LinkCreated { get; set; }
}
So, to load a link and its tags, I’d need to use two navigation properties, and refer to the joining table when performing queries:
var linksAndTags
= context.Links
.Include(e => e.LinkTags)
.ThenInclude(e => e.Tag)
.ToList();
With many-to-many in EF Core 5, I can skip over the join table and use direct navigation properties. We can instead get a little more direct:
public class Link
{
public int LinkId { get; set; }
public string Description { get; set; }
public List<Tag> Tags { get; set; } // Skips right to Tag
public List<LinkTag> LinkTags { get; set; }
}
public class Tag
{
public string TagId { get; set; }
public string Description { get; set; }
public List<Link> Links { get; set; } // Skips right to Link
public List<LinkTag> LinkTags { get; set; }
}
Look how easy querying is now:
var linksAndTags
= context.Links
.Include(e => e.Tags)
.ToList();
In the standup, Arthur Vickers mentioned an important fact that’s easy to overlook: while the release timing is similar, EF Core 5 is not bound to .NET 5. It targets .NET Standard 2.1, so can be used in any .NET Core 3.x apps (and of course is available for use in .NET 5). Take a look at the docs to learn more about .NET Standard compatibility.
Checking in on NuGet changes
This week, the .NET Tooling community standup brought in the NuGet team to talk about what they’re working on. They mentioned three key things: UX enhancements to nuget.org, improvements to package compatibility in Visual Studio, and better README support for package authors.
The team has been working on improving the experience on nuget.org—in the last few weeks, they’ve blogged about how you can use advanced search and also view dependent packages. While I prefer to work with packages in my IDE, you can hit up nuget.org for a better view, but it’s hard to filter through the noise. The new filtering options are a welcome improvement: I can filter by dependencies, tools, templates, relevance, downloads, and prereleases. Whether I value stability or finding out what’s new, the experience is a lot better now.
I was most interested to hear about tooling support, as that’s how a lot of us use NuGet most. The team discussed upcoming changes to floating version support. Floating version support means you’re using the latest version of a range you specify: for example, if you say you want version 2.*
of a package, and it rolled out 1.0
, 2.0
, and 2.1
versions, you’re using 2.1
. Soon, you’ll be able to specify this in the Version
field in the NuGet UI—preventing you from hacking away from the project file. As a whole, the Version
field will allow more flexibility and not just be a drop-down.
Lastly, if you author NuGet packages, README links will no longer be a post-package upload but built right into the Visual Studio Package Properties. That will allow you to easily have your package documentation on nuget.org, and the NuGet UI in Visual Studio will have a link to it.
🌎 Last week in the .NET world
🔥 The Top 3
- Matt Mitchell does a deep dive on how .NET builds and ships.
- Jeremy Likness inspects and mutates IQueryable expression trees.
- Matthew Jones uses conditional C# LINQ clauses to make a multiple-input search engine.
📢 Announcements
- Phillip Carter is looking for feedback on the .NET project system in Visual Studio.
- Jon Gallant talks about the August release of the Azure SDKs, and Jianghao Lu shows us what’s new in the Azure Identity release.
- Azure Cosmos DB serverless is now in preview.
- You can now view dependent packages on nuget.org.
- AWS SDK for .NET v3.5 is generally available.
- Mads Kristensen announces his new stream, where he writes or updates Visual Studio extensions.
📅 Community and events
- The .NET Docs Show talks with Rachel Appel.
- We had three community standups this week: .NET tooling talks about NuGet improvements, Entity Framework talks many-to-many, and ASP.NET talks .NET 5 stuff.
😎 Blazor
Jon Hilton compares Blazor and Vue, and also works with client-side Blazor.
🚀 .NET Core
- Tomasz Pęczek supports encrypted content encoding in .NET Core.
- The Code Maze blog works with IncludeMembers and custom projections with AutoMapper in ASP.NET Core, discusses how to implement SignalR automatic reconnect with Angular, and adds gRPC to an ASP.NET Core project and MongoDB.
- Gunnar Peipman logs NHibernate SQL to ASP.NET Core loggers.
- Damien Bowden works through symmetric and asymmetric encryption in .NET Core.
- Andrew Lock controls the IHostedService execution order in ASP.NET Core 3.x.
- ErikEJ maps and uses SQL Server stored procedures with EF Core Power Tools, and uses SQL Server Compact 4 with .NET Core 3.1 on Windows.
⛅ The cloud
- Matias Quaranta works with HttpClientFactory in the Azure Cosmos DB .NET SDK.
- At the Azure Community Blog, a look at Dapr.
- Will Velida explores Azure Cosmos DB serverless.
- Dominique St-Amand uses path-based routing in Azure Application Gateway with Azure WebApps.
- Damien Bowden secures Azure Functions using API keys.
- Jason Farrell keeps going on Azure Durable Functions, with approving the upload.
- Daniel Krzyczkowski uses event sourcing with Azure Cosmos SB change feed and Azure Functions.
📔 Languages
- Thomas Claudius Huber talks about top-level statements in C# 9.
- Anthony Giretti makes options immutable in ASP.NET Core 5 and C# 9, and looks at native-sized integers in C# 9.
- Khalid Abuhakmeh uses the select drop-down in ASP.NET Razor.
- Roland Weigelt creates a thumbnail for video and image files in C#.
- Gunnar Peipman uses Structuremap in legacy ASP.NET MVC apps.
🔧 Tools
- Trevor Sullivan works with Visual Studio Code and Error Lens.
- Matthew MacDonald discusses the design patterns programmers really use.
- Dave Brock (ahem) takes a look at Project Tye for microservices development.
- Mathankumar Rajendran develops an ASP.NET Core app using VS Code.
- Mark Seemann says unit testing is fine.
- Vinicius Apolinario extracts a web app from IIS to create a new container image.
- Rami Honig discusses the top 10 open source NuGet tools for .NET development.
📱 Xamarin
- James Montemagno talks about app first run detection with Xamarin.Essentials.
- Matthew Leibowitz works through templated controls.
- Jonathan Peppers profiles Xamarin.Android startup.
- David Britch connects to localhost over HTTPS for (Xamarin) Android release builds.
- Jesse Liberty walks through the MonkeyCache library.
🎤 Podcasts
- At Developer Tea, 4 things you have to leave behind as a beginning engineer.
- The Stack Overflow podcast asks: should managers of developers ever make technical decisions?.
- The .NET Rocks podcast talks with Philip Carter about F#.
- The Azure DevOps Podcast talks to Brady Gaster about SignalR and more.
- The Coding Blocks Podcast keeps working on the DevOps Handbook, talking about anticipating problems.
- The 6 Figure Developer podcast talks about BlazorCMS and SpeakerMeet.
- The No Dogma podcast talks to Mads Torgersen about C# 9.
🎥 Videos
- The ON.NET Show adds a little Swagger to OData.
- Data Exposed improves query performance by managing statistics in Azure SQL.
- The Xamarin Show talks about the new Drawing API.
- Brian Lagunas asks whether to use ConfigureAwait True or False.