Technologies and Tools for .NET Developers
In our previous article, we covered what .NET is and the main features that drove .NET to be the framework of choice for millions of developers around the world, and how it allows them to create solid applications for any platform, from desktop and mobile to the web and cloud.
But the framework itself is only the tip of the iceberg when it comes to the .NET environment. Let’s take a dive into the complementary technologies and tools that make working with .NET so beneficial.
Table Of Contents
LINQ
Language Integrated Query (LINQ) is one of the things that makes working with .NET a breeze. It was introduced in .NET Framework 3.5 back in 2007.
Integrating a querying language into any programming language is feasible through a set of constructs that provide powerful search capabilities within the programming language syntax. LINQ introduced new models for data manipulation. Such models can be extended to potentially query any type of data source.
This set of .NET technologies make it easier for developers to work with data, as it treats the queries as a first-class programming language construct. This allows us to model a database through classes and then search the database, as well as insert, update or delete data. LINQ supports transactions, views and stored procedures. It also provides an easy way to integrate data validation and business logic rules.
LINQ has a set of query operators which form the LINQ pattern to work with data. Calls to query methods can be chained together in one query, which enables queries to become arbitrarily complex.
By using LINQ, we get the following advantages:
- Written code is simplified: any developer that already knows programming and a querying language like SQL will find LINQ quite intuitive.
- Syntax unification for querying any data source: you can search an XML or JSON document in the same way as a database, a DataSet, an in-memory collection, or any other remote or local data source that has LINQ support.
- Strengthens the connection between relational data and the object-oriented world: this is because querying becomes a first-class programming language construct. Queries can be strongly typed and .NET developer tools can be used to create relational object diagrams.
- Shorter development time: by catching many errors at compile time it’s easy to spot errors during development. There is also support for IntelliSense and debugging.
Entity Framework
Entity Framework (EF) is the Object Relational Mapping (ORM) technology developed by Microsoft that makes it easy to work with database data. It enables .NET developers to work with data using objects of domain-specific classes without focusing on the underlying database tables and columns where data is indeed stored. With EF, developers can work at a higher level of abstraction when processing data and can create and maintain data-oriented applications with less code compared to traditional applications.
EF and LINQ make a great couple. It’s really straightforward to compose database queries and EF has great support for LINQ operators that get translated to SQL code to be executed on the database server.
Entity Framework main features include:
- Cross-platform: EF Core version is a cross-platform framework that can run on Windows, Linux and Mac.
- Modeling: EF creates an EDM (Entity Data Model) based on POCO (Plain Old CLR Object) entities with get/set properties of different data types. It uses this model when querying or saving entity data to the underlying database.
- Querying: EF allows us to use LINQ queries to retrieve and process data from the underlying database. The database provider will translate LINQ queries to the database-specific query language (e.g. SQL for a relational database). EF also allows us to execute raw SQL queries directly to the database.
- Change Tracking: EF keeps track of changes done to instances of entities (property values) that need to be submitted to the database.
- Saving: EF executes INSERT, UPDATE, and DELETE commands to the database based on the changes that occurred to entities when you call the context SaveChanges() method. There’s also an asynchronous SaveChangesAsync() version of this method.
- Concurrency: EF uses Optimistic Concurrency by default to protect overwriting changes made by another user since data was fetched from the database.
- Transactions: EF performs automatic transaction management while querying or saving data. It also provides options to customize transaction management.
- Caching: EF includes first-level caching out of the box. So, repeated querying will return data from the cache instead of hitting the database.
- Built-in Conventions: EF follows conventions over the configuration programming pattern, and includes a set of default rules which automatically configure the EF model.
- Configurations: EF allows us to configure the EF model by using data annotation attributes or Fluent API to override default conventions.
- Migrations: EF provides a set of migration commands that can be executed to create or manage the underlying database Schema.
Entity Framework supports many database flavors, these being the main ones:
- SQL Server
- SQL Server Compact
- Oracle
- SQLite
- PostgreSQL
- MySQL and MariaDB
- Cosmos DB SQL API
- DB2
- Firebird
- In memory (for testing)
For more, here’s a full list of compatible database providers.
EF is also open source. See its GitHub repository as well as a specific Entity Framework Core repository.
IDEs: Visual Studio and Visual Studio Code
An IDE is an Integrated Development Environment. When it comes to .NET, the most common options are the full-fledged Visual Studio and the lighter Visual Studio Code.
Visual Studio (VS) is currently offered in 3 flavors:
- Visual Studio Community (free)
- Visual Studio Professional
- Visual Studio Enterprise
Visual Studio has been around since 1997, shortly before .NET was first introduced. VS 2002 was the first version with support for .NET 1.0 and since then it has evolved a lot and has full support for .NET native programming languages. The current version, Visual Studio 2019, supports lots of features. Amongst them it’s worth mentioning the following ones:
- Best-in-class .NET tools and services for any app and any platform.
- Great code search capabilities
- Wise refactorings. Making your code easier to read and maintain is super easy in VS thanks to its integrated refactoring tools. For instance, you can extract a method or move a type with just a couple clicks.
- IntelliCode – it’s IntelliSense on steroids that uses artificial intelligence to suggest code recommendations. The AI is trained\fed with 2,000 open-source projects on GitHub—each with over 100 stars—to generate its recommendations.
- Code cleanup
- Integrated Test environment with Test explorer
- Pair programming capabilities
- Git integration
- Live Share allows sharing a codebase and its context with someone. We get instant bidirectional collaboration directly from within Visual Studio. The person on the other end can read, navigate, edit and debug a project that’s being shared, and do so seamlessly and securely.
- Integrated code review using an extension.
- Visual Studio marketplace Extensions – allows new features to be added on top of VS.
Visual Studio Code or just VS Code on the other hand is a lightweight IDE and supports many of the features of its big brother. It was first released in 2015. It’s open-source and is used for cross-platform development. It has an active community that takes advantage of its extensibility points. Like VS, VS Code has an extension library that allows .NET developers to add languages, debuggers, and tools to support many different development workflows.
One of its great features is that the developer can build code for Java, JavaScript, Go, Node.js, Python, C++, etc., through extensions. As you see, it has support for practically any programming language you throw at it, meaning it isn’t only tied to .NET native languages.
Visual Studio Code combines the simplicity of a source code editor with powerful developer tooling, like IntelliSense code completion and debugging. As the folks behind it say: “First and foremost, it is an editor that gets out of your way. The delightfully frictionless edit-build-debug cycle means less time fiddling with your environment, and more time executing on your ideas.”
It’s highly customizable to fit any developer’s needs.
Visual Studio Code main features include:
- Available for macOS, Linux, and Windows
- Light-weight (small installation size)
- Extensible: install just the things you need to use
- Out-of-the-box tools for developing for the web: JavaScript and TypeScript, JSX/React, HTML, CSS, SCSS, Less, and JSON.
- Edit, build, and debug with ease
Package Manager (NuGet)
NuGet is the .NET package manager. The NuGet Gallery is the central package repository used by all package authors and consumers. Its client is open-source. NuGet’s main purpose is to make it easier to share, organize and keep track of libraries installed in a given .NET solution\project. It appeared in 2010 to solve a significant problem that developers always had: to share and reuse code (class libraries) across different solutions or projects.
With NuGet, there’s no need to store the libraries\packages’ source-code in Git anymore. Package metadata is stored in the project definition file (.csproj for C# for example). When a .NET developer clones the Git repository which contains a solution with many projects or even a standalone project and builds it for the first time, Visual Studio will automatically restore (download all the dependencies/NuGet packages, described in the .csproj) right from the NuGet package source or your own defined package source. This saves a lot of storage space on any Git repository, makes it faster to clone the repo, and guarantees that you’ll get the correct version for each library, preventing any version mismatch.
Figure 2 – as of July 2021, the NuGet Gallery has 267,413 packages available to download
Visual Studio has great UI integration to manage all the libraries supporting our solution’s projects.
Another way of managing NuGet packages is through NuGet’s CLI (command line interface). It allows us to execute package managing tasks to produce and consume packages, update, check package info, etc in a straightforward way.
Even Microsoft releases its libraries into smaller packages through NugGet like for example System.Net.Http.Json. This makes it easy for the developer to install just the necessary libraries for any given project. We can also choose which library version to install. There’s a version history table available for comparison.
Opening any given NuGet package by using the FuGet package explorer we can check .NET framework versions supported by that specific package version and the list of dependencies the package consumes. We can even navigate through the package source-code at will.
For a more detailed NuGet description, be sure to check out this page.
Developing for the Cloud (Azure)
With Microsoft Azure or just Azure, you can take advantage of .NET on the cloud; Azure is Microsoft’s take on the cloud. It was released back in October 2008.
Azure offers cloud computing services letting companies and developers build, test, deploy and manage applications and services through Microsoft-managed data centers. As we’d expect, it has full support for .NET and its related .NET technologies through service offerings such as SQL Database (Managed Cloud Database Service) and Active Directory (Azure AD).
In recent years we’ve seen a surge in moving things to be online and available 24/7 on the internet. Systems and their data are moved from on-premises to the cloud where they can be kept secure, backed up and replicated, being serviced by regionalized data-centers. This is effective in many ways, such as increase in performance, decreased data loss risk, better security enforcement and cost reduction, just to mention a few. The cloud takes away the burden of keeping web-servers and all infrastructure involved which deviates from our main purpose which is building and shipping software products.
For .NET developers, Azure is integrated in many workflows, including within Visual Studio. A C# .NET Web application can be deployed with the click of a button to any given app service, having it ready for consumption in a matter of seconds.
Azure has a free tier that allows the use of 25+ services forever and other popular services are free for 1 year. It does have a huge ecosystem. As of now, it offers 200+ services that can be consumed on-demand, that is, you pay just for what you need and use. This allows for greater flexibility. One can configure an application to only use the services and processing power that are needed at the moment. If the app’s audience grows and more power is demanded, it’s just a matter of bumping the current app’s capacity accordingly; likewise, if some degree of economy is necessary, scaling down is just as easy.
Azure DevOps
Azure DevOps is the icing on the cake for anyone developing with .NET. It’s a place where we can plan, code, collaborate, and ship applications. With the increasing number of developers working from home, it’s the perfect place to manage their work in a centralized place.
Any company or solo developer can create projects on DevOps. Projects are the root concept. Within a project, we have a set of highly customizable features to manage such a project like adding\removing users, creating groups of users, configuring specific user or group permissions, etc.
One of its great offerings is the ability to track product backlog items tightly integrated with Git workflows. For example, a team manager can create a group of developers and assign specific tasks to each one of them. Developers can then start working on their tasks, and when finished, submit a pull request targeting the work item at hand. Once this pull request is approved, the work item can be marked as ready or done automatically. There are many possible workflows to set up. You can make it fit any style of workflow.
Everything gets tracked within DevOps, allowing the developer or manager to check a feature’s progress step by step; line by line of code. DevOps main features include:
- Azure Boards: a place where we can manage a project’s work items, backlogs, sprints, setup customized queries, delivery plans, calendars, etc. Deliver value to users faster using proven agile tools to plan, track, and discuss work across your teams.
- Repos: a place where we can manage the actual project’s source code with sections for Files, Commits, Pushes, Branches, Tags and Pull Request. Unlimited, cloud-hosted private Git repos foster collaboration to build better code with pull requests and advanced file management.
- Pipelines: a place where we can manage shipping releases. Its sections include Pipelines, Environments, Releases, Library, Tasks Groups, Deployment Groups and XAML. Build, test, and deploy with CI/CD that works with any language, platform, and cloud. Connect to GitHub or any other Git provider and deploy continuously. There are build extensions that allow for a great customization experience.
- Test Plans: a place to manage tests targeting the project with Progress report, Runs and Load Test. Test and ship with confidence using manual and exploratory testing tools.
- Artifacts: create, host, and share packages with your team, and add artifacts to your CI/CD pipelines with a single click.
It’s important to mention that DevOps is available for any programming language and any platform, not only .NET. To get a glimpse of all this, you can watch this video from the Azure DevOps YouTube channel.
Conclusion
As we’ve seen, there are plenty of technologies and tools that boost .NET’s capabilities to the next level and enhance our developer experience during all of the stages of a software product. From incredibly easy database manipulation to smooth cloud deployment, powerful editors and the ability to further extend its powers with third-party tools, the .NET environment has a lot to offer.