Welcome to my blog!

How to backup/restore a Firebird database?

May 19, 2021 16:31

How to backup/restore a Firebird database? (edit)

How to backup/restore a Firebird database? - Stack Overflow

** Visual Studio 2019 Developer Command Prompt v16.9.4
** Copyright (c) 2021 Microsoft Corporation


C:\>cd "C:\Program Files\Firebird\Firebird_3_0\"

C:\Program Files\Firebird\Firebird_3_0>gbak -c -user SYSDBA -password masterkey C:\Git\DB\Test.bak C:\Git\DB\Test.fdb

C:\Program Files\Firebird\Firebird_3_0>

Connection String

<add name="TestContext" connectionString="character set=none; data source=localhost;initial catalog=Test; port number=3050; user id=sysdba; dialect=3; password=masterkey;Max Pool Size=1000" providerName="FirebirdSql.Data.FirebirdClient" />

Test DB Connection (DBeaver 21.0.0)

C:\>cd "C:\Program Files\Firebird\Firebird_3_0\"

C:\Program Files\Firebird\Firebird_3_0>Notepad++ databases.conf

# ------------------------------
# List of known databases
# ------------------------------

# Makes it possible to specify per-database configuration parameters.
# See the list of them and description on file firebird.conf.
# To place that parameters in this file add them in curly braces
# after "alias = /path/to/database.fdb" line. Example:
# big = /databases/bigdb.fdb
# {
# LockMemSize = 32M # We know that bigdb needs a lot of locks
# LockHashSlots = 19927 # and big enough hash table for them
# }

# Example Database:
employee.fdb = $(dir_sampleDb)/employee.fdb
employee = $(dir_sampleDb)/employee.fdb

test = C:/Git/DB/Test.FDB

# Master security database specific setup.
# Do not remove it until you understand well what are you doing!
security.db = $(dir_secDb)/security3.fdb
RemoteAccess = false
DefaultDbCachePages = 50

# Live Databases:

Result is


DDL Firebird + Firebird Version

April 25, 2021 22:39

DDL Firebird C# (edit)

  • Determine Firebird Version
  • How to detect the server version
  • Create Database from scratch
  • Create Table from scratch

Determine Firebird Version

SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION')
FROM rdb$database;

The database experts Doc/Firebird 3.0 DDL triggers (ibexpert.net)

How to use Firebird with .Net? (firebirdfaq.org)

Embedded Firebird: Full-Featured Embedded Database with 2 MB Runtime - CodeProject

c# - How do INSERT INTO Firebird, with autoincrement for the primary key? - Stack Overflow

Create Database + Determine Firebird Version

using FirebirdSql.Data.FirebirdClient;
using System;
using System.Data;
using System.Diagnostics;

namespace ConsoleApp1
class Program
private static string m_ConnectionString = "";

private static void Main(string[] args)
string exeFilePath = @"C:\Program Files\Firebird\Firebird_3_0\gstat.exe";
string firebirdDBFilePath = @"C:\Git\DB\asclepiosqualificationNew.FDB";
string exeArgs = $" -h {firebirdDBFilePath}";


System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = exeFilePath;
proc.StartInfo.Arguments = exeArgs;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
string output = proc.StandardOutput.ReadToEnd();
string[] arrOutput = output.Split(System.Environment.NewLine);
foreach (var line in arrOutput)
if (line.Contains("ODS version"))
string[] arr = line.Trim().Split("ODS version");
if (arr.Length > 0)
string version = arr[1].Trim();
switch (version)
case "10":
case "10.0":
version = "Firebird 1";

case "11":
case "11.0":
case "11.2":
version = "Firebird 2.5";

case "12":
case "12.0":
version = "Firebird 3";

case "13":
case "13.0":
version = "Firebird 4";


FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
builder.DataSource = "localhost";
builder.UserID = "SYSDBA";
builder.Password = "masterkey";
builder.Database = "Test";
//builder.Database = @"C:\Git\DB\Test.fdb";
//builder.ServerType = FbServerType.Embedded;
builder.ServerType = FbServerType.Default;
//{"Dynamic SQL Error\r\nSQL error code = -104\r\nToken unknown - line 1, column 14\r\nUSER"}
m_ConnectionString = builder.ConnectionString;




private static void CreateTables()
//https://stackoverflow.com/questions/43020306/how-do-insert-into-firebird-with-autoincrement-for-the-primary-key (HAY)

private static void CreateDatabase()
catch (Exception ex)

private static DataTable CallStoredProcedure()
DataTable table = new DataTable();
using (var con = new FbConnection(m_ConnectionString))
using (var cmd = new FbCommand("usp_GetUsers", con))
using (var da = new FbDataAdapter(cmd))
cmd.CommandType = CommandType.StoredProcedure;
return table;

private static DataTable CallStored()
var dt = new DataTable();

using (var con = new FbConnection(m_ConnectionString))
using (var cm = new FbCommand("usp_GetUsers", con))
cm.CommandType = CommandType.StoredProcedure;

using (var da = new FbDataAdapter(cm))

return dt;

Create Tables

using FirebirdSql.Data.FirebirdClient;
using FirebirdSql.Data.Isql;
using System;
using System.Diagnostics;

namespace ConsoleApp2
internal class Program
private static SolutionType solutionType = SolutionType.FbScriptFB2_5;

private static void Main(string[] args)
var connectionString = new FbConnectionStringBuilder
Database = @"C:\Git\DB\Test.fdb",
ServerType = FbServerType.Default,
UserID = "SYSDBA",
Password = "masterkey",
DataSource = "localhost"


using (FbConnection connection = new FbConnection(connectionString))
using (FbCommand cmd = new FbCommand())

cmd.Connection = connection;
switch (solutionType)
case SolutionType.Firebird3:

case SolutionType.Firebird2_5:

case SolutionType.FbScriptFB2_5:

cmd.CommandText = @"insert into withgeneratedid(column2) values (@column2) returning id";
cmd.Parameters.AddWithValue("@column2", "some value");
cmd.Parameters.Add(new FbParameter() { Direction = System.Data.ParameterDirection.Output });

Console.WriteLine("Id:" + cmd.Parameters[1].Value);

private static void Firebird3Example(FbCommand cmd)
// Firebird 3 identity column
cmd.CommandText = @"create table withgeneratedid(
id integer generated by default as identity primary key,
column2 varchar(100)

private static void Firebird2_5Example(FbCommand cmd)
// Firebird 2.5 and earlier normal primary key with trigger to generate key
// Table
cmd.CommandText = @"create table withgeneratedid(
id integer primary key,
column2 varchar(100)

// Sequence
cmd.CommandText = "create sequence seq_withgeneratedid";

// Trigger
cmd.CommandText = @"create trigger withgeneratedid_bi before insert on withgeneratedid
if (new.id is null) then new.id = next value for seq_withgeneratedid;

private static void FbScriptFB2_5Example(FbCommand cmd)
string script = @"
create table withgeneratedid(
id integer primary key,
column2 varchar(100)

create sequence seq_withgeneratedid;

set term #;
create trigger withgeneratedid_bi before insert on withgeneratedid
if (new.id is null) then new.id = next value for seq_withgeneratedid;
set term ;#
FbScript fbScript = new FbScript(script);
FbBatchExecution exec = new FbBatchExecution(cmd.Connection);

public enum SolutionType

ASP.NET Firebird Telerik Kendo UI

April 19, 2021 23:09

ASP.NET Firebird Telerik Kendo UI (edit)

  • MediatR
  • CQRS
  • Entity Framework
  • Firebird
  • Autofac
  • AutoMapper
  • DBeaver
  • Telerik UI for ASP.NET MVC
  • DevExpress ASP.NET MVC
  • jQuery Ajax
  • ASP.NET MVC Razor views
  • Unit Testing in .NET: The Complete Guide
    • What unit tests are
    • Advantages of unit testing
    • Disadvantages and limitations
    • Unit testing best practices
    • What Mocking is
    • Mocking frameworks
    • Executing unit tests with the help of a mocking framework
    • Introduction to code coverage
    • When to choose your tooling

Kendo UI:

First Steps with Your Kendo UI for jQuery Project Guide | Getting Started | Kendo UI for jQuery | Kendo UI for jQuery (telerik.com)

jQuery Demos and Examples with HTML5/JavaScript Source Code | Kendo UI for jQuery (telerik.com)

Twitter Bootstrap and jQuery Responsive Demo | Kendo UI for jQuery (telerik.com)

Tales of Kendo UI Awesomeness: AdvancedREI (telerik.com)

Telerik UI for ASP.NET MVC:

ASP.NET MVC Introduction | Telerik UI for ASP.NET MVC

Telerik UI for ASP.NET MVC Demos

ASP.NET MVC UI Controls for Fast App Development | Telerik UI for ASP.NET MVC

Kendo UI vs UI for ASP.NET MVC

Kendo UI


Telerik UI for ASP.NET MVC


Kendo UI vs UI for ASP.NET MVC - Telerik Blogs (HAY HAY HAY)

Difference between KendoUI Professional and Kendo UI MVC | static void main(string[] args) (wordpress.com) (HAY HAY HAY)

UI for ASP.NET MVC vs Kendo UI Complete in Kendo UI for jQuery General Discussions - Telerik Forums (HAY HAY HAY)

The combination of two different Telerik products helps level the playing field for all types of web developers: Kendo UI and UI for ASP.NET MVC. Whether you are an enterprise ASP.NET developer, a JavaScript champion or someone in between, these web development tools are flexible and can adapt to your needs.

Kendo UI may be the only JavaScript framework that you need to add to your web project.

UI for ASP.NET MVC UI suite is squarely meant for ASP.NET MVC developers like you – allowing you to leverage all the Kendo UI client-side widgets through easy MVC wrappers.

UI for ASP.NET MVC is not just MVC wrappers for Kendo UI though – it also includes framework pieces and Visual Studio goodies for the .NET developer. Using Kendo UI widgets via UI for ASP.NET MVC suite gives you the client-side UI functionality while having all the server-side comforts.

Also note that Telerik UI for ASP.NET MVC includes server-side wrappers for Kendo UI Web, Kendo UI DataViz and Kendo UI Mobile.

Directly to your questions:

  • Kendo UI Web targets primarily desktop, but it is touch-enabled and will operate properly on mobile devices as well. Specifically for mobile development with adaptive look and feel on different platforms, you can employ Kendo UI Mobile.
  • Yes, you can use MVC Razor views for mobile development. Also note that Telerik UI for ASP.NET MVC includes server-side wrappers for Kendo UI Web, Kendo UI DataViz and Kendo UI Mobile.
  • The difference between Kendo UI Complete and UI for ASP.NET MVC is that the latter incorporates ASP.NET MVC server wrappers, which allow you to define your code logic in server code and utilize features of the ASP.NET MVC framework.

Finally, note that Telerik.Web.Mvc.dll is an assembly from a discontinued product (Telerik MVC Extensions). Its successor product code, Telerik UI for ASP.NET MVC, resides in Kendo.Mvc.dll.

Regards, Sebastian


Video: Intro to MediatR - Implementing CQRS and Mediator Patterns - YouTube

Video: Vertical Slice Architecture - Jimmy Bogard - YouTube

Building MVC Jimmy Style (thefreezeteam.azurewebsites.net)

CQRS (martinfowler.com)

Command Query Separation (martinfowler.com)

PDF: CQRS Documents by Greg Young (wordpress.com)


Thin Controllers with CQRS and MediatR (codeopinion.com)

Thin Controllers using MediatR with ASP.NET MVC | Alex Lindgren

Simplify your controllers with the Command Pattern and MediatR (jonhilton.net)

Moving from Controllers and Actions to Endpoints with MediatR | Blog (ardalis.com)

Using Scaffold-DbContext in EF Core 2.1 with Firebird database

April 17, 2021 22:03

Using Scaffold-DbContext in EF Core 2.1 with Firebird database (edit)

Currently supported by EF Core:

  • Microsoft SQL Server
  • SQLite
  • Postgres (Npgsql)
  • SQL Server Compact Edition
  • InMemory (for testing purposes)
  • MySQL
  • IBM DB2
  • Oracle
  • Firebird

Forcus on:

  • .NET Core 2.1
  • EF Core 2.1
  • Firebird Database
  • Scaffold-DbContext
  • Generate Models from Existing Database


  • .NET Core 2.1
  • ASP.NET Core MVC 2.1
  • Install-package EntityFrameworkCore.FirebirdSql -Version
  • Install-package Microsoft.EntityFrameworkCore -Version 2.1.14
  • Install-package Microsoft.EntityFrameworkCore.Tools -Version 2.1.14

EF 6:

  • EntityFramework (EF 6)
  • EntityFramework.SqlServerCompact (EF 6)

EF Core:

  • Microsoft.EntityFrameworkCore
  • FirebirdSql.Data.FirebirdClient
  • FirebirdSql.EntityFrameworkCore.Firebird

.NET Provider for Firebird

  • Firebird ADO.NET Data Provider
  • Microsoft SQL Server Compact Data Provider 4.0
  • More ...

How to build a Connection String?

Class: FirebirdSql.Data.FirebirdClient.FbConnectionStringBuilder

var connectionString = new FbConnectionStringBuilder
Database = "mydb",
DataSource = "localhost",
ServerType = FbServerType.Default,
UserID = "sysdba",
Password = "masterkey",

How to use Scaffold-DbContext?

Scaffold-DbContext "character set=none;data source=localhost;initial catalog=mydb;user id=sysdba;password=masterkey;" EntityFrameworkCore.FirebirdSql -Force -OutputDir Models

Scaffold-DbContext "User=xxxx;Password=xxxx;Database=xxxx;DataSource=xxxxxx;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0;" FirebirdSql.EntityFrameworkCore.Firebird -OutputDir Models

.NET Core CSharp Project (.csproj)

<Project Sdk="Microsoft.NET.Sdk.Web">


<PackageReference Include="EntityFrameworkCore.FirebirdSql" Version="" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.14">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>


Next with .NET Core 3.1:

  • .NET Core 3.1
  • ASP.NET Core MVC 3.1
  • EF Core 3.1

Next with .NET Core 5.0:

  • .NET Core 5.0
  • ASP.NET Core MVC 5.0
  • EF Core 5.0



https://github.com/ralmsdeveloper/EntityFrameworkCore.FirebirdSQL (HAY HAY HAY)

https://www.programmersought.com/article/6109272731/ (HAY HAY HAY)






April 9, 2021 16:30

Firebird (edit)

Raw SQL Queries - EF6 | Microsoft Docs

Execute Raw SQL Query in Entity Framework 6 (entityframeworktutorial.net)

Executing Raw SQL Queries using Entity Framework Core | Learn Entity Framework Core

EntityFramework.Docs/raw-sql.md at main · dotnet/EntityFramework.Docs · GitHub

Executing Raw SQL Queries using Entity Framework | BinaryIntellect Knowledge Base

Sample/Program.cs at master · kowill/Sample · GitHub


Recent posts