Database to code with a Firebird database
    de en

Database to code with a Firebird database

2018, Apr 21    

Database to Code with a Firebird Database

Generate Models, Controller and Views in a “ASP.Net Core Web Application” using a existing Firebird Database

Step 1: Create a ASP.Net Core Web Application

Step 2: Add the following nuget-packages

  • EntityFrameworkCore.FirebirdSql
  • Microsoft.AspNetCore.All
  • Microsoft.NETCore.App
  • Microsoft.VisualStudio.Web.CodeGeneration.Design

Step 3: Build and Save the connection string to your DB

Using example values.

String for dbfilename.fdb

Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;

Step 4: Use Scaffold to reverse the DB-Models

Use the following command, for example in the Package Manager Console

Scaffold-DbContext "User=sysdba;Password=masterkey;Database=/firebird/data/dbfilename.fdb;
DataSource=;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;
EntityFrameworkCore.FirebirdSQL -o Models

Step 5: Generate Controller and View

Right-Click on your project -> Add -> New Scaffolded Item… -> MVC Controller with views, using Entity Framework


The data context class is generated for all Models of the database.

Step 6: Small Modification

Add in Startup.cs -> ConfigureServices(IServiceCollection services)

   options => options.UseFirebird(

Add this constructor in _firebird_data_dbfilename_fdbContext

public _firebird_data_dbfilename_fdbContext(DbContextOptions<_firebird_data_dbfilename_fdbContext> options) 

Step 7: View the result

Just start without debugging and put the Controller name without “Controller” at the end of the url. http://localhost:51710/AddContacts