Skip to main content
net6.0-windows7.0

LCPI Entity Framework Core provider for «LCPI ADO.NET Provider for OLE DB».

Published
Sep 1, 2023
3y ago
Total Downloads
5.2K
5,161

Install

dotnet add package Lcpi.EntityFrameworkCore.DataProvider.LcpiOleDb --version 6.0.21.201
ProductVersions
.NET
net6.0-windows7.0

README

EF Core Provider for «LCPI ADO.NET Provider for OLE DB» v6.0

Lcpi.EntityFrameworkCore.DataProvider.LcpiOleDb is an open source EF Core provider for «LCPI ADO.NET Provider for OLE DB».

Currently it allows you to interact with Firebird v3 via Microsoft Entity Framework Core v6.0.

Attention

This provider doesn't look and doesn't feel like any other Entity Framework Core provider.

Target platform

  1. NET6 (Windows)
  2. Entity Framework Core v6.0
  3. Firebird v3.0.8
  4. LCPI ADO.NET Provider for OLE DB
  5. LCPI.IBProvider v5

Example of usage

////////////////////////////////////////////////////////////////////////////////
//Please use correct TargetPlatform: net6.0-windows7.0
////////////////////////////////////////////////////////////////////////////////

using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

////////////////////////////////////////////////////////////////////////////////
//TEST TABLE

/*
RECREATE TABLE DBMS
(
 ID BIGINT GENERATED BY DEFAULT AS IDENTITY CONSTRAINT PK_DBMS PRIMARY KEY,

 NAME VARCHAR(32) CHARACTER SET UTF8,

 DESCRIPTION VARCHAR(128) CHARACTER SET UTF8
);
*/ 

////////////////////////////////////////////////////////////////////////////////

const string c_Dbms_Name ="Firebird";
const string c_Dbms_Descr="Of course I still \u2764 you! \ud83d\ude04"; // ;)
 
////////////////////////////////////////////////////////////////////////////////

try
{
 //---------------------------- INSERT
 Console.WriteLine("Inserting new record...");
 
 using var db=new MyDbContext();
 
 using var tr=db.Database.BeginTransaction();

 var newRecord=new DatabaseServer{ Name=c_Dbms_Name, Description=c_Dbms_Descr };
 
 db.DatabaseServers!.Add(newRecord);
 
 db.SaveChanges();
 
 var newRecordID=newRecord.ID;
 
 Console.WriteLine("newRecordID: {0}",newRecordID);
 
 //---------------------------- SELECT
 Console.WriteLine("Selecting inserted record...");
 
 var recs
  =db
   .DatabaseServers
   .Where(r => r.Description!.Length==c_Dbms_Descr.Length && r.ID==newRecordID)
   .Select(r => new {ServerName=r.Name!});
 
 int nRec=0;
 
 foreach(var r in recs)
 {
  ++nRec;
 
  Console.WriteLine("{0}. {1}",nRec, r.ServerName);
 }//foreach r

 if(nRec!=1)
  throw new ApplicationException("Oh sh...");
 
 //---------------------------- DELETE
 Console.WriteLine("Deleting inserted record...");
 
 db.DatabaseServers.Remove(newRecord);
 
 db.SaveChanges();

 tr.Commit();
}
catch(Exception ex)
{
 for(var e=ex;e!=null;e=e.InnerException)
 {
  Console.WriteLine
   ("--- ERROR: {0}\n{1}",
    e.Source,
    e.Message);
 }//for e
}//catch

// Cleanup ....
GC.Collect();
GC.WaitForPendingFinalizers();

////////////////////////////////////////////////////////////////////////////////

sealed class MyDbContext:DbContext
{
 private const string c_CnStr
  ="provider=LCPI.IBProvider.5;"
   +"location=inet4://localhost/d:\\database\\ram\\ibp_test_fb30_d3.gdb;"
   +"dbclient_type=fb.direct;"
   +"user id=SYSDBA;"
   +"password=masterkey;"
   +"auto_commit=true;"
   +"wchars_in_utf8_symbol=2;"; //Enabling full UTF8 support. Because we can.

 public DbSet<DatabaseServer>? DatabaseServers { get; set; }

 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
  optionsBuilder.UseLcpiOleDb(c_CnStr);
 }
};//class DbContext

////////////////////////////////////////////////////////////////////////////////

[Table("DBMS")]
sealed class DatabaseServer
{
 [Key]
 public long ID { get; set; }

 [Column("NAME", TypeName="VARCHAR(32) CHARACTER SET UTF8")]
 public string? Name { get; set; }

 [Column("DESCRIPTION", TypeName="VARCHAR(128) CHARACTER SET UTF8")]
 public string? Description { get; set; }
};//class DatabaseServer

////////////////////////////////////////////////////////////////////////////////

Output:

Inserting new record...
newRecordID: 8
Selecting inserted record...
1. Firebird
Deleting inserted record...

Related packages

Changes from Previous Version

No structural changes between v6.0.21.200 and v6.0.21.201.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.