.NET MAUI (Multi-platform App UI) is a cross-platform framework for building desktop and mobile applications using C# and XAML. It allows creating applications running on Windows, macOS, and Android operating systems, all from one Codebase.
Oracle Database is a robust, commercial relational database management system (RDBMS) developed by Oracle Corporation. It delivers comprehensive SQL implementation, enterprise-grade scalability, built-in high availability, performance optimization, and extensive management tools.
Thus, Oracle Database is a preferred choice for large organizations that require industrial-strength database solutions.
Why dotConnect for Oracle?
Advanced ORM support
Fully supports EF Core, Dapper, NHibernate, LinqConnect, and other technologies for efficient data management.
Full ADO.NET compliance
Conforms to the latest ADO.NET standards and innovations for seamless integration with .NET applications.
Oracle-specific data types
Offers many Oracle-specific features and fully supports all unique data types for accurate and complete data representation.
Secure connection options
Provides robust security with support for SSL/SSH connections, connecting via proxy servers, embedded servers, and HTTP tunneling.
IDE integration
Features native integration with Visual Studio and complete design-time support for accelerated development.
Priority support & frequent updates
Includes priority support, detailed documentation, and regular updates for continuous improvement.
Download and activate dotConnect for Oracle
You can start using dotConnect for Oracle immediately with a 30-day free trial. Choose one of the following installation options:
Using the built-in Data Explorer, first, configure the connection to Oracle and then select the objects you want to use in your project.
1. In Visual Studio, click Tools on the menu bar and select Connect to Database from the drop-down list.
2. In the Add Connection window, choose the Oracle data source, fill in the connection details for your Oracle database, and click OK to proceed.
3. In Server Explorer, select the tables and fields you want to use. In our tutorial, we will use the EMPLOYEES table.
Connect and retrieve Oracle data
In this foundational step, our goal is to establish a connection to the Oracle database and display data in a read-only list. This ensures our database connection is correctly configured and provides the base upon which we will build the other CRUD operations.
The data model (Employee.cs)
First, create a new C# class file named Employee.cs. This class will serve as a model to store each employee record retrieved from the database.
Next, create the DatabaseConnection.cs file. This class centralizes our connection string, making it easy to manage. We use Devart.Data.Oracle with Direct=True to connect directly to the Oracle server without requiring an Oracle Client installation.
Oracle System Identifier (SID) for the database instance.
UserId
User ID used to authenticate with Oracle.
Password
Password for the user ID.
License Key
Your license key. This is required only when using .NET Standard compatible assemblies.
The data service (EmployeeService.cs)
Create an EmployeeService.cs file. We will start by adding a single method, GetAllEmployees, that queries the database and returns a list of all employees.
<!-- OracleMAUI/MainPage.xaml --><?xml version="1.0" encoding="utf-8" ?><ContentPagexmlns="http://schemas.microsoft.com/dotnet/2021/maui"xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"x:Class="OracleMAUI.MainPage"Title="Employee Management"><GridRowDefinitions="Auto,*,Auto"Padding="20"RowSpacing="15"><!-- Input Form --><GridGrid.Row="0"ColumnDefinitions="*,*,*"ColumnSpacing="10"RowDefinitions="Auto,Auto"Margin="0,0,0,20"><Entryx:Name="FirstNameEntry"Placeholder="First Name"Grid.Row="0"Grid.Column="0" /><Entryx:Name="LastNameEntry"Placeholder="Last Name"Grid.Row="0"Grid.Column="1" /><Entryx:Name="EmailEntry"Placeholder="Email"Grid.Row="0"Grid.Column="2"Keyboard="Email" /><GridGrid.Row="1"Grid.ColumnSpan="3"ColumnDefinitions="*,*,*"ColumnSpacing="10"><ButtonText="Insert"Clicked="OnInsertClicked"Grid.Column="0" /><ButtonText="Update"Clicked="OnUpdateClicked"Grid.Column="1" /><ButtonText="Delete"Clicked="OnDeleteClicked"Grid.Column="2"BackgroundColor="#D32F2F" /></Grid></Grid><!-- Employee List --><ListViewx:Name="EmployeeListView"Grid.Row="1"ItemSelected="OnEmployeeSelected"><ListView.ItemTemplate><DataTemplate><ViewCell><HorizontalStackLayoutPadding="10"><LabelText="{Binding EmployeeId, StringFormat='ID: {0}'}"WidthRequest="60" /><LabelText="{Binding FirstName}"WidthRequest="100" /><LabelText="{Binding LastName}"WidthRequest="100" /><LabelText="{Binding Email}"WidthRequest="150" /><LabelText="{Binding HireDate, StringFormat='{0:yyyy-MM-dd}'}"HorizontalOptions="EndAndExpand" /></HorizontalStackLayout></ViewCell></DataTemplate></ListView.ItemTemplate></ListView><!-- Status Bar --><Labelx:Name="StatusLabel"Grid.Row="2"Text="Ready"HorizontalOptions="Center" /></Grid></ContentPage>
The UI logic (MainPage.xaml.cs)
Update the code-behind file, MainPage.xaml.cs. The code will call the LoadEmployees method from the constructor, ensuring the data is fetched immediately upon application launch.
You have now built a functional, read-only .NET MAUI application that connects to an Oracle database and displays the data. This confirms that your core setup is working correctly.
Insert Oracle data
We will now enhance the application by adding the ability to create new records. This involves adding input fields and a button to the UI and implementing the logic to execute an INSERT SQL statement.
Update the UI (MainPage.xaml)
Modify MainPage.xaml to add Entry fields for the first name, last name, and email, and an Insert button. The main grid layout is adjusted to accommodate these new elements, with all inputs in a single row and a margin below them.
<!-- OracleMAUI/MainPage.xaml --><?xml version="1.0" encoding="utf-8" ?><ContentPagexmlns="http://schemas.microsoft.com/dotnet/2021/maui"xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"x:Class="OracleMAUI.MainPage"Title="Employee Management"><GridRowDefinitions="Auto,*,Auto"Padding="20"RowSpacing="15"><!-- Input Form --><GridGrid.Row="0"ColumnDefinitions="*,*,*"ColumnSpacing="10"RowDefinitions="Auto,Auto"Margin="0,0,0,20"><Entryx:Name="FirstNameEntry"Placeholder="First Name"Grid.Row="0"Grid.Column="0" /><Entryx:Name="LastNameEntry"Placeholder="Last Name"Grid.Row="0"Grid.Column="1" /><Entryx:Name="EmailEntry"Placeholder="Email"Grid.Row="0"Grid.Column="2"Keyboard="Email" /><GridGrid.Row="1"Grid.ColumnSpan="3"ColumnDefinitions="*,*,*"ColumnSpacing="10"><ButtonText="Insert"Clicked="OnInsertClicked"Grid.Column="0" /><ButtonText="Update"Clicked="OnUpdateClicked"Grid.Column="1" /><ButtonText="Delete"Clicked="OnDeleteClicked"Grid.Column="2"BackgroundColor="#D32F2F" /></Grid></Grid><!-- Employee List --><ListViewx:Name="EmployeeListView"Grid.Row="1"ItemSelected="OnEmployeeSelected"><ListView.ItemTemplate><DataTemplate><ViewCell><HorizontalStackLayoutPadding="10"><LabelText="{Binding EmployeeId, StringFormat='ID: {0}'}"WidthRequest="60" /><LabelText="{Binding FirstName}"WidthRequest="100" /><LabelText="{Binding LastName}"WidthRequest="100" /><LabelText="{Binding Email}"WidthRequest="150" /><LabelText="{Binding HireDate, StringFormat='{0:yyyy-MM-dd}'}"HorizontalOptions="EndAndExpand" /></HorizontalStackLayout></ViewCell></DataTemplate></ListView.ItemTemplate></ListView><!-- Status Bar --><Labelx:Name="StatusLabel"Grid.Row="2"Text="Ready"HorizontalOptions="Center" /></Grid></ContentPage>
Update the data service (EmployeeService.cs)
Add the InsertEmployee method to your EmployeeService.cs file. This method takes the first name, last name, and email, connects to the database, and executes a parameterized INSERT query. Devart's Oracle provider uses the :paramName syntax for bind parameters.
Modify MainPage.xaml.cs to handle the new functionality. Add a private field _selectedEmployee and create the OnInsertClicked and ClearForm methods, both updated to manage the Email field.
The application can now add new records to the database. Users can enter data, click the Insert button, and see the list update immediately to reflect the new entry.
Update Oracle data
In this step, we will implement the ability to edit existing records. This requires logic to select an item from the list, populate the input fields with its data, and then save the changes with an UPDATE SQL command.
Update the UI (MainPage.xaml)
In MainPage.xaml, add an Update button next to the Insert button and attach an ItemSelected event handler to the ListView. The UI layout has also been updated to reflect a single-row input layout.
Add the OnEmployeeSelected and OnUpdateClicked methods to MainPage.xaml.cs. OnEmployeeSelected will populate the form with all employee data, including email, when a user taps an item in the list. OnUpdateClicked saves the changes and passes the email to the service.
// OracleMAUI/MainPage.xaml.cs// ... (add these methods inside the MainPage class)privatevoidOnEmployeeSelected(object? sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem is Employee employee)
{
_selectedEmployee = employee;
FirstNameEntry.Text = employee.FirstName;
LastNameEntry.Text = employee.LastName;
EmailEntry.Text = employee.Email;
}
}
privateasyncvoidOnUpdateClicked(object? sender, EventArgs e)
{
if (_selectedEmployee == null)
{
await DisplayAlert("Validation", "Please select an employee to update.", "OK");
return;
}
var firstName = FirstNameEntry.Text?.Trim();
var lastName = LastNameEntry.Text?.Trim();
var email = EmailEntry.Text?.Trim();
if (string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(lastName) || string.IsNullOrWhiteSpace(email))
{
await DisplayAlert("Validation", "Please enter first name, last name, and email.", "OK");
return;
}
try
{
EmployeeService.UpdateEmployee(_selectedEmployee.EmployeeId, firstName, lastName, email);
StatusLabel.Text = $"Updated: {firstName}{lastName}";
ClearForm();
LoadEmployees();
}
catch (Exception ex)
{
StatusLabel.Text = $"Error: {ex.Message}";
}
}
The application now supports editing data. Users can select an employee, change their details in the input form, and save the changes back to the database.
Delete Oracle data
In the final step, we will implement the delete functionality. This involves adding a Delete button and the logic to execute a DELETE SQL command, including a confirmation step to prevent accidental data loss.
Update the UI (MainPage.xaml)
Modify MainPage.xaml to include a Delete button, completing our CRUD controls set. The UI layout is consistent with the single row input form.
// OracleMAUI/EmployeeService.cs// ... (add this method inside the EmployeeService class)publicstaticvoidDeleteEmployee(int employeeId)
{
usingvar connection = DatabaseConnection.GetConnection();
connection.Open();
usingvar command = new OracleCommand(
"DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID = :employeeId",
connection);
command.Parameters.Add(new OracleParameter("employeeId", employeeId));
command.ExecuteNonQuery();
}
Update the UI logic (MainPage.xaml.cs)
Finally, add the OnDeleteClicked method to MainPage.xaml.cs. This method first confirms the user's action with a pop-up dialog before proceeding with deletion.
// OracleMAUI/MainPage.xaml.cs// ... (add this method inside the MainPage class)privateasyncvoidOnDeleteClicked(object? sender, EventArgs e)
{
if (_selectedEmployee == null)
{
await DisplayAlert("Validation", "Please select an employee to delete.", "OK");
return;
}
var confirm = await DisplayAlert("Confirm Delete",
$"Delete employee {_selectedEmployee.FirstName}{_selectedEmployee.LastName}?",
"Yes", "No");
if (!confirm) return;
try
{
EmployeeService.DeleteEmployee(_selectedEmployee.EmployeeId);
StatusLabel.Text = $"Deleted: {_selectedEmployee.FirstName}{_selectedEmployee.LastName}";
ClearForm();
LoadEmployees();
}
catch (Exception ex)
{
StatusLabel.Text = $"Error: {ex.Message}";
}
}
You have now completed the application. It has full CRUD functionality, allowing users to read, create, update, and delete records from the Oracle database in a user-friendly way.
Video tutorial: How to connect .NET MAUI application to Oracle database
Conclusion
In this guide, we've explored how to perform essential CRUD operations using Oracle in a .NET MAUI application.
With these steps, you have gained a foundational understanding of how to expand your app's functionality and interact with complex data.
Continue experimenting with these operations to build, optimize, and customize your applications to meet new data needs.
FAQ
How do you install and activate dotConnect for Oracle in a .NET project?
Install dotConnect for Oracle via the EXE installer or by adding the Devart.Data.Oracle NuGet package to your project, then obtain your personal activation key from your Devart Customer Portal and include it in the connection string via the License Key parameter for a working connection.
How do you create a connection to Oracle using dotConnect in C#?
Define a connection string that includes host, user ID, password, database, and the License Key value, then create an OracleConnection instance with this string and call Open() for it inside a try-catch block to test and handle connection errors.
How do you enable encryption for secure Oracle connections with dotConnect?
Use Oracle Native Network Encryption by configuring encryption in the sqlnet.ora file on both client and server sides. No special parameters are required in the connection string.
Can you connect to Oracle using Entity Framework Core and dotConnect?
Yes, you can either use Entity Developer to visually create an EF Core model from the database or run Scaffold-DbContext with a dotConnect connection string (including License Key) to generate the DbContext and entity classes.
Is it possible to connect to Oracle using Visual Studio Server Explorer with dotConnect?
Yes, it is possible. All you need to do is navigate to Visual Studio Server Explorer, add a new Data Connection, choose dotConnect for Oracle as the data provider, enter your credentials, test the connection, and then browse Oracle data directly in Visual Studio.
I'm a technical content writer who loves turning complex topics — think SQL, connectors, and backend chaos–into content that actually makes sense (and maybe even makes you smile). I write for devs, data folks, and curious minds who want less fluff and more clarity. When I'm not wrangling words, you'll find me dancing salsa, or hopping between cities.