Finally, Microsoft has released a new NuGet package (rebranded as of 2021/03/05) with which it adds a lot of interesting scenarios with the possibility to connect to Microsoft Dataverse using .Net Core clients.
All the authentication flows supported by the old CrmServiceClient are supported by ServiceClient but we want to show how we used the ClientSecret authentication flow to connect to Microsoft Dynamics.
So we start by creating a simple console application using .Net Core v3.1 and install Microsoft.PowerPlatform.Dataverse.Client NuGet Package (v0.4.3 as of 2021/03/05). It is no longer important to check the "Include prerelease" flag, even though the package is still in Alpha, because Microsoft decided to drop the prerelease flag to increase visibility.

Then you can use the following snippet of code to get up and running with your test. You should change the connection string with your environment variables.
using Microsoft.Extensions.Configuration;
using Microsoft.PowerPlatform.Dataverse.Client;
using Microsoft.PowerPlatform.Dataverse.Client.Utils;
using System;
using System.IO;
namespace Dataverse_Console_App
{
class Program
{
static void Main(string[] args)
{
IConfiguration config =
new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true)
.Build();
var dataverseClientConfig = new ClientConfig();
config.GetSection("DataverseClient").Bind(dataverseClientConfig);
try
{
var cdsClient = new ServiceClient(
dataverseClientConfig.Uri,
dataverseClientConfig.ClientId,
dataverseClientConfig.ClientSecret,
dataverseClientConfig.UseUniqueInstance);
Console.WriteLine("Hello, connected to Microsoft Dataverse using .NET Core");
}
catch (DataverseConnectionException ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.InnerException);
}
Console.ReadKey();
}
}
}The following is the ClientConfig implementation.
using System;
namespace Dataverse_Console_App
{
public class ClientConfig
{
public Uri Uri { get; set; }
public string ClientId { get; set; }
public string ClientSecret { get; set; }
public bool UseUniqueInstance { get; set; }
}
}For this flow, we need to first create an Application Registration in Active Directory. So we navigate to portal.azure.com and then we open Azure Active Directory. On the side menu, we choose App Registrations. Click on + New Registration and fill the following screen

Personal thought! The information popup should have been a warning popup as you need to make sure you copy and backup this key somewhere safe.
At this point, if you try connecting to your instance of Microsoft Dynamics the error you get is not very helpful "The HTTP request was forbidden with client authentication scheme 'Anonymous'.", but this error just means that we have not registered our application with Microsoft Dynamics yet. I reported this here and a fix will be implemented soon.
We need to add an application user to our dynamics instance.

Now you can connect to your Dataverse Instance, but don't forget to assign roles to your Application User if you want to really use this application. Also, you might consider giving some additional grants to your application such as User Impersonation. Be sure to use the latest available package, there was a bug when you try setting CdsServiceClient.CallerId the call gets ignored and this property is always Guid.Empty, which was resolved in version v0.2.1-Alpha after I reported the issue here. User Impersonation works if CdsServiceClient.CallerAADObjectId is used instead.