New sponsor Devart: DMVCFramework ActiveRecord now works on UniDAC
🇮🇹 Italiano • 🇪🇸 Español • 🇩🇪 Deutsch • 🇧🇷 Português • 🇫🇷 Français

With DelphiMVCFramework 3.5, TMVCActiveRecord also works with Devart's UniDAC connections. What do you need to install, what do you need to write if you start from scratch, and what happens to a program that uses FireDAC today? I took one and ran it with both libraries.
In short: in DelphiMVCFramework 3.5, TMVCActiveRecord works on Devart UniDAC connections. You configure each connection with a connect string and the provider-specific options, in the project’s .env file or in code, and FireDAC remains the default library.
Thanks to Devart for the support and for making DelphiMVCFramework even better. Devart is a company founded in 1997 that develops database tools, data access components, ODBC drivers and data integration solutions. Over the years several users have asked for UniDAC support, and now, thanks to Devart, the community gets this feature as well, in DelphiMVCFramework 3.5.0-silicon.
Along with Devart, I want to thank the other sponsors who support the project:
- bit Time Professionals, the company where I am CEO and CTO: it does consulting, design, training and software development. It is based in Rome.
- bit Time Software, a software house founded in 2002. It represents Embarcadero in Italy.
- Centro Software, which develops ERP and other digital solutions for business management. It is based in the province of Bologna.
- Delphi Studio, which does consulting, training and development in Valencia.
- Orion Law, which develops practice management software for law firms. It is based in West Palm Beach, Florida.
- Vivaticket, which offers systems and services for ticketing and for the management of events and venues: theaters, trade fairs, theme parks, sports and live shows.
DelphiMVCFramework has been used in production since 2010. On GitHub it has over 1,400 stars, and since 2017 it has been the Delphi project of its kind with the most stars. The license is Apache 2.0, so you can use it for free, even in products you sell. More than 6,000 people are members of the Facebook group.


Version 3.5.0-silicon is the first AI-Ready version: it includes a number of optimizations, the skills for AI agents and the wizards to create MCP servers.
Over the years the framework has been chosen for mission-critical systems: banking APIs that process transactions worth millions of euros, hospital systems that manage patients’ vital signs, industrial platforms that coordinate production lines. I wrote about this in the post on Bloom filters: these are systems that handle millions of API calls a day.
That is why several companies, some of the most important in their industries, sponsor the project. Some fund the development of specific features, others provide free licenses to help it evolve. Devart is one of the latter.
What UniDAC is and what Devart sponsored

UniDAC (Universal Data Access Components) is Devart’s data access library for Delphi, C++Builder and Lazarus. With the same components you connect to different databases, each with its own provider.
Devart sponsored DelphiMVCFramework with perpetual UniDAC licenses, used to develop support for this library in TMVCActiveRecord.
If you use FireDAC, you don’t have to do anything. FireDAC remains the default library and your code stays as it is.
What you need to use TMVCActiveRecord with UniDAC
You need DelphiMVCFramework 3.5.0-silicon.
You also need UniDAC, which is a commercial product: it has its own license and is installed separately. The framework does not contain it: the dmvcframeworkRT and dmvcframeworkDT packages compile even if you don’t have UniDAC.
For a normal executable you need nothing else. Your library path already has the framework sources: add UniDAC, then put MVCFramework.ActiveRecord.UniDAC and the provider unit of your database in the uses clause:
| Database | Provider unit |
|---|---|
| PostgreSQL | PostgreSQLUniProvider |
| Firebird and InterBase | InterBaseUniProvider |
| MySQL and MariaDB | MySQLUniProvider |
| SQL Server | SQLServerUniProvider |
| Oracle | OracleUniProvider |
| SQLite | SQLiteUniProvider |
If you build with runtime packages, you also need dmvcframeworkUniDAC. It is in the zip, in the folder of your Delphi version (from packages\d102 to packages\d130), and it is not part of the groupproj. Open it and compile it after dmvcframeworkRT. It is runtime-only: you don’t need to install anything in the IDE.
UniDAC support has been tested with Delphi 13 Florence and UniDAC 12.1.0. The full DelphiMVCFramework test suite has 2,168 unit tests, and the one that checks ActiveRecord with UniDAC has 721: both run on Win32 and on Win64. The package files also exist for Delphi 10.2 through 12, but I have not compiled them with UniDAC. If you compile them, let me know how it went.
The code that ActiveRecord runs with UniDAC does not use FireDAC types. The executable still contains the FireDAC units, because the TMVCActiveRecord API is still the one from 3.4: some methods, for example MapTValueToParam, take FireDAC parameters.
How to configure a UniDAC connection in .env or in code
You configure a UniDAC connection the same way you would without DelphiMVCFramework: a connect string and the provider-specific options (SpecificOptions), using the names from the UniDAC documentation. You write them in the project’s .env file, with the unidac. prefix and the connection name:
unidac.mydb.ConnectString=Provider Name=PostgreSQL;Server=localhost;Database=mydb;User ID=app;Password=secret;Pooling=True
unidac.mydb.SpecificOptions.UseUnicode=True
Each specific option goes on its own line: unidac.<name>.SpecificOptions.<Option> or, with the provider name, unidac.<name>.SpecificOptions.<Provider>.<Option>. At startup, before the first connection, you load the definitions:
uses
MVCFramework.ActiveRecord.UniDAC, PostgreSQLUniProvider;
...
AddUniDACConnectionDefsFromDotEnv; // every unidac.* definition in the .env
lEngine.Use(ActiveRecordHTTPFilter('mydb')); // one TUniConnection for every HTTP request
From then on, you can use the name mydb wherever you used to put the name of a FireDAC definition: AddConnection(name, def), AddDefaultConnection(def), ActiveRecordHTTPFilter and ActiveRecordEndpointFilter. Entities, RQL and queries stay as they are.
If you would rather not use the .env, write the same definition in code:
AddUniDACConnectionDef('mydb',
'Provider Name=PostgreSQL;Server=localhost;Database=mydb;User ID=app;Password=secret;Pooling=True',
['UseUnicode=True']);
AddUniDACConnectionDefsFromDotEnv calls AddUniDACConnectionDef for every connection it finds in the .env. If a definition is wrong, the exception is raised when the program starts. That happens with a connect string that UniDAC rejects, a misspelled unidac.* key, the options of a connection without ConnectString, and a name defined twice.
The unidac. prefix keeps each library’s keys apart in the same .env, alongside your application’s own keys.
ActiveRecord sets no UniDAC defaults
Every connection created from a definition is a new TUniConnection with that connect string and those options. The framework adds nothing of its own: a property you don’t set keeps the UniDAC default, today and after a UniDAC update. Pooling, login prompt, character set and Unicode are up to you.
ActiveRecord does need two options, though, and if they are missing the framework logs a warning:
EnableMemos=Trueon Firebird and InterBase, otherwise text blobs are read as binary;UseUnicode=Trueon Oracle, otherwise anINSERTwith a CLOB column fails with ORA-24816.
Without UseUnicode=True, on any provider UniDAC converts text to the ANSI code page, and you get ?? instead of an emoji. Set it, unless the database deliberately uses a non-Unicode character set.
With SQLite and multiple connections to the same file (threads, named connections) you need LockingMode=lmNormal and a BusyTimeout: with the UniDAC defaults the file stays locked and the other connections don’t wait.
How to migrate an ActiveRecord project from FireDAC to UniDAC
If you have a FireDAC-based project and want to switch to UniDAC, follow these steps:
In the
usesclause addMVCFramework.ActiveRecord.UniDACand the provider unit of your database.For every FireDAC definition you use (in
FDConnectionDefs.inior inFDManager.AddConnectionDef) write a UniDAC definition with the same name in the.env.Rewrite every parameter of the FireDAC definition in the UniDAC definition, with the UniDAC names. The framework does not read the FireDAC definition to build the UniDAC connection: the UniDAC connection has only what you write in the
.env, and a parameter you don’t carry over stays at the UniDAC default. Parameter names differ between the two libraries. These are the most common:In the FireDAC definition In the UniDAC definition Server,Port,Database,Passwordsame names, in the ConnectStringUser_NameUser ID, in theConnectStringPooled=TruePooling=True, in theConnectStringPOOL_MaximumItemsMax Pool Size, in theConnectStringCharacterSetSpecificOptions.CharsetOSAuthent=Yes(SQL Server)SpecificOptions.Authentication=auWindowsFor the other parameters, look up the option that does the same thing in the documentation of the UniDAC provider.
At startup, before the first connection, call
AddUniDACConnectionDefsFromDotEnv.
The calls that use that name (AddConnection, AddDefaultConnection, ActiveRecordHTTPFilter, ActiveRecordEndpointFilter) stay as they are. Before you switch libraries, also check the points listed further on, in What to check in your code before migrating to UniDAC.
The same program running on FireDAC and on UniDAC
Let’s try it. This program reads three customers and runs an UPDATE on the samples’ PostgreSQL database. With the -unidac parameter it loads the UniDAC definitions from the .env, otherwise it uses FireDAC. The connection name is the same.
The entity, in the EntU.pas unit:
type
[MVCNameCase(ncLowerCase)]
[MVCTable('customers')]
TCustomer = class(TMVCActiveRecord)
private
[MVCTableField('id', [foPrimaryKey, foAutoGenerated])]
fID: Int64;
[MVCTableField('description')]
fDescription: string;
[MVCTableField('city')]
fCity: string;
public
property ID: Int64 read fID write fID;
property Description: string read fDescription write fDescription;
property City: string read fCity write fCity;
end;
The program:
program TwoLibs;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.Generics.Collections,
FireDAC.Comp.Client, FireDAC.Stan.Def, FireDAC.Stan.Async, FireDAC.DApt,
FireDAC.Phys.PG, FireDAC.ConsoleUI.Wait,
MVCFramework.ActiveRecord,
MVCFramework.SQLGenerators.PostgreSQL,
MVCFramework.ActiveRecord.UniDAC,
PostgreSQLUniProvider,
EntU in 'EntU.pas';
begin
FDManager.ConnectionDefFileName := 'FDConnectionDefs.ini';
if FindCmdLineSwitch('unidac') then
AddUniDACConnectionDefsFromDotEnv; // the unidac.* keys of the .env file
ActiveRecordConnectionsRegistry.AddDefaultConnection('activerecorddb');
try
WriteLn('Connection: ', TMVCActiveRecord.CurrentARConnection.ConnectionObject.ClassName);
var lCustomers := TMVCActiveRecord.SelectRQL<TCustomer>('sort(+id)', 3);
try
for var lCustomer in lCustomers do
WriteLn(Format('%d %s (%s)', [lCustomer.ID, lCustomer.Description, lCustomer.City]));
finally
lCustomers.Free;
end;
var lRows := TMVCActiveRecord.ExecSQL(
'update customers set rating = rating where city = ?', ['Melbourne']);
WriteLn('Rows updated: ', lRows);
finally
ActiveRecordConnectionsRegistry.RemoveDefaultConnection;
end;
end.
The two configurations sit next to the executable. The FDConnectionDefs.ini file:
[activerecorddb]
DriverID=PG
Server=localhost
Database=activerecorddb
User_Name=postgres
Password=postgres
Pooled=True
And the .env file:
unidac.activerecorddb.ConnectString=Provider Name=PostgreSQL;Server=localhost;Database=activerecorddb;User ID=postgres;Password=postgres;Pooling=True
unidac.activerecorddb.SpecificOptions.UseUnicode=True
With FireDAC:
C:\DEV\TwoLibs>TwoLibs.exe
02/12/2026 23:46:16[TID 17504][DEBUG] ActiveRecord: Add "EntU.TCustomer:" to the metadata cache
Connection: TFDConnection
22869 Burger Inc. (Melbourne)
22870 House SPA (London)
22871 House Corp. (Melbourne)
Rows updated: 11
With UniDAC (the dotEnv lines log the loading of the .env file):
C:\DEV\TwoLibs>TwoLibs.exe -unidac
02/12/2026 23:46:16[TID 3028][INFO] Initializing default dotEnv instance
02/12/2026 23:46:16[TID 3028][INFO] dotEnv: Path = C:\DEV\TwoLibs
02/12/2026 23:46:16[TID 3028][INFO] dotEnv: Active profile/s priority = [default,test,prod] (Priority: FileThenEnv)
02/12/2026 23:46:16[TID 3028][INFO] dotEnv: Applied file C:\DEV\TwoLibs\.env
02/12/2026 23:46:16[TID 3028][INFO] dotEnv: Missed file C:\DEV\TwoLibs\.env.test
02/12/2026 23:46:16[TID 3028][INFO] dotEnv: Missed file C:\DEV\TwoLibs\.env.prod
02/12/2026 23:46:16[TID 3028][DEBUG] ActiveRecord: Add "EntU.TCustomer:" to the metadata cache
Connection: TUniConnection
22869 Burger Inc. (Melbourne)
22870 House SPA (London)
22871 House Corp. (Melbourne)
Rows updated: 11
How to register a TUniConnection you create yourself
If you create the connection yourself, you register it like this:
uses
Uni, PostgreSQLUniProvider, MVCFramework.ActiveRecord,
MVCFramework.SQLGenerators.PostgreSQL,
MVCFramework.ActiveRecord.Connection, MVCFramework.ActiveRecord.UniDAC;
...
lConn := TUniConnection.Create(nil);
lConn.ConnectString := 'Provider Name=PostgreSQL;Server=localhost;Database=mydb;' +
'User ID=me;Password=secret;Login Prompt=False';
lConn.SpecificOptions.Values['UseUnicode'] := 'True';
AddDefaultUniDACConnection(lConn, aoOwned);
With aoOwned, the ActiveRecord registry frees the connection. For the other connections there is AddUniDACConnection('name', lConn).
The uses clause also includes the database’s SQL generator, MVCFramework.SQLGenerators.PostgreSQL. As with FireDAC, it registers itself: just add it to the uses clause of any unit in the project.
In a server, however, a definition is the better choice: the ActiveRecordHTTPFilter('mydb') filter opens a connection for every HTTP request and releases it at the end of the request, even when the action raises an exception. If you haven’t seen HTTP filters yet, I talk about them in this post.
Writing code that works with both FireDAC and UniDAC connections
Every ActiveRecord method that accepts a TFDConnection has a twin that accepts a TCustomConnection. So you can pass a TUniConnection in the same places: TMyEntity.Create(lConn), AddDefaultConnection(lConn, True), the Select and Where methods that receive the connection, TMVCRepositoryWithConnection<T>.Create(lConn).
If you need a connection of your own and want the code to work with both libraries, have the registry create it:
var
lConn: TCustomConnection; // unit Data.DB
lCustomer: TCustomer;
begin
lConn := ActiveRecordConnectionsRegistry.CreateConnection('activerecorddb');
try
lCustomer := TCustomer.Create(lConn);
try
lCustomer.LoadByPK(22869);
WriteLn(lConn.ClassName, ' ', lCustomer.Description);
finally
lCustomer.Free;
end;
finally
lConn.Free;
end;
end;
CreateConnection returns a new connection from the library that name is defined for: you must free it yourself.
For hand-written SQL, use TMVCActiveRecord.ExecSQL(SQL, Params), as in the program above. It returns the number of affected rows and accepts the ? and :name placeholders.
What to check in your code before migrating to UniDAC
Some methods return a TFDConnection, so with UniDAC they raise EMVCActiveRecord. Look for them in your code:
| Raises the exception with UniDAC | What to use instead |
|---|---|
TMVCActiveRecord.CurrentConnection | TMVCActiveRecord.CurrentARConnection |
TMVCActiveRecord.GetConnectionByName | ActiveRecordConnectionsRegistry.GetConnectionByName |
ActiveRecordConnectionsRegistry.GetCurrent | ActiveRecordConnectionsRegistry.GetCurrentConnection |
ActiveRecordConnectionsRegistry.GetByName | ActiveRecordConnectionsRegistry.GetConnectionByName |
TMVCRepository<T>.GetConnection | the entity’s GetARConnection |
If you use CurrentConnection to call ExecSQL, switch to TMVCActiveRecord.ExecSQL. The new methods return an IMVCActiveRecordConnection. If you really need the TUniConnection, it is in ConnectionObject.
Also look for entities that override MapTValueToParam or MapObjectToParams. They receive FireDAC parameters, so on a UniDAC connection they raise EMVCActiveRecord, and the message names the entity. On FireDAC they work as before.
ActiveRecord reads are forward-only with both libraries: the Select methods that fill the objects, GetByPK and SelectUnidirectionalDataSet do not keep the whole result in memory. With UniDAC this means UniDirectional, and the UniDAC documentation describes what that entails on some providers. On PostgreSQL, outside a transaction, UniDAC opens an internal connection to read with a cursor (the options to look at are CursorWithHold and MultipleConnections). On SQL Server without MARS it opens an extra session (MultipleActiveResultSets). On MySQL it locks the connection until the read finishes, or creates another one (CreateConnection). With the options in parentheses you decide how UniDAC behaves in these cases.
If you prefer to hand the migration over to an AI agent, the changelog has a block of instructions ready to copy: Switching from FireDAC to UniDAC. The agent makes the mechanical changes and leaves you a list of files and lines to check by hand.
How UniDAC support is tested, and the sample to look at
The ActiveRecord test suite runs in full with UniDAC on Firebird, PostgreSQL, MariaDB, SQL Server and Oracle (in Direct mode). SQLite has a dedicated suite. If you have the repository, Delphi 13 and UniDAC, the command below compiles and runs everything, for Win32 and Win64. Before that, you have to start SQL Server and Oracle with Docker, and for the FireDAC tests on Oracle you need the Instant Client: the details are in the comments of tasks.py.
python -m invoke tests-unidac
The sample to look at is activerecord_showcase. It contains two projects that use the same units: activerecord_showcase.dproj for FireDAC and activerecord_showcase_unidac.dproj for UniDAC. The difference is the ConnectionConfigUniDACU unit, which uses AddUniDACConnectionDef to define, for UniDAC, the same connection name that the FireDAC project takes from the FireDAC definitions. The Oracle part of the showcase is not implemented.
Thank you, Devart
Thanks to Devart for the sponsorship and for giving me the tools to develop and test this feature.
If your company uses DelphiMVCFramework and wants to sponsor a feature it needs, write to me at professionals@bittime.it.
– Daniele Teti
Comments