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

Nugets:

  • .NET Core 2.1
  • ASP.NET Core MVC 2.1
  • Install-package EntityFrameworkCore.FirebirdSql -Version 2.1.2.2
  • 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",
}.ToString();

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">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EntityFrameworkCore.FirebirdSql" Version="2.1.2.2" />
<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">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project> 

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

References:

https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient

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

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

https://hoanguyenit.com/create-database-using-code-first-in-aspnet-core-21.html

https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro?view=aspnetcore-5.0

http://www.binaryintellect.net/articles/87446533-54b3-41ad-bea9-994091686a55.aspx

https://docs.oracle.com/cd/E17952_01/connector-net-en/connector-net-entityframework-core-example.html