XPO - .NET Core Enhancements (v18.1)

XPO Team Blog
09 May 2018

Extended database support
With our upcoming release (v18.1), XPO for .NET Core / .NET Standard 2.0 will support the Oracle Data Provider 12.2 for .NET Core in addition to SQL Server, MySql, PostgreSQL, FireBird and SQLite. As we noted in our introductory post, the lack of support for other providers is not a limitation of XPO - only a function of support from RDBMS vendors. Once these RDBMS vendors support .NET Standard 2.0, we will test XPO against these backend providers and will add them to our supported list once our internal qualification requirements have been met. See Also: How to implement a custom XPO connection provider for AdoNetCore.AseClient.

XPO Profiler supports ASP.NET Core projects
As some of you already know, XPO Profiler is a tool designed to discover performance bottlenecks and code issues. Profiling logs include SQL queries, session method calls, query duration, passed parameters, and callstacks. To enable performance profiling in your ASP.NET Core projects, you'll need to add a special API Controller:

using Microsoft.AspNetCore.Mvc;
using DevExpress.Xpo.Logger;

namespace DevExpress.Xpo.AspNetCoreMvcDemo.Controllers {
    public class XpoLoggerController : Controller {
        readonly static LoggerBase logger = new LoggerBase(50000);
        static XpoLoggerController() {
        public LogMessage[] GetCompleteLog() {
            return logger.GetCompleteLog();
        public LogMessage GetMessage() {
            return logger.GetMessage();
        public LogMessage[] GetMessages(int messagesAmount) {
            return logger.GetMessages(messagesAmount);
Complete documentation will ship with our official v18.1 release:  Connect the XPO Profiler to an ASP.NET Core Application. In the meantime, you can use our GitHub demo with the current beta.

Dependency Injection for ASP.NET Core projects
We've implemented new extension methods for the standard IServiceCollection interface to register useful XPO services for the ASP.NET Core pipeline. This follows best practices for the platform and allows you to automatically manage XPO’s data layer and session life cycle as needed.

To call these extensions, the Microsoft.Extensions.DependencyInjection namespace must be imported. Here is an example of the modified ConfigureServices method in the Startup class inside an ASP.NET Core project:

        public void ConfigureServices(IServiceCollection services) {
            services.AddXpoDefaultUnitOfWork(true, options =>
                    .UseEntityTypes(new Type[] { typeof(User) })

You can access  or resolve the UnitOfWork service in your Controllers (example), Views markup or Startup (example) class using standard ASP.NET Core techniques. For more information, refer to the Dependency injection in ASP.NET CoreDependency injection into controllers in ASP.NET Core and Dependency injection into views in ASP.NET Core articles in Microsoft documentation.  Additional XPO examples will be available with the official release at ASP.NET Core Dependency Injection in XPO.

BONUS: I also have an XPO .NET Core version up and running with the Mono runtime on WebAssembly in a Blazor app for both standalone and ASP.NET Core hosted deployment. The example below was used for the in-memory data store within a web browser:

            var serviceProvider = new BrowserServiceProvider(services => {
                services.AddXpoDefaultUnitOfWork(true, options =>
                    .UseEntityTypes(new Type[] { typeof(WeatherForecast) })

NOTE: we do not officially support WebAssembly-based .NET runtimes at this stage (and of course, Blazor is currently an experimental project). I did this test just for fun and research purposes.  Are you also interested in testing XPO with Blazor? Leave a comment to this post and I will email you my working XPO sample.

Love XPO and want to help us promote it? Add the package through Nuget.org instead of DevExpress Nuget!

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.