前言
Firebird 是一个跨平台的关系数据库系统,目前能够运行在 Windows、linux 和各种 Unix 操作系统上,提供了大部分 SQL-99 标准的功能。它既能作为多用户环境下的数据库服务器运行,也提供嵌入式数据库的实现。
Firebird 脱胎于 Borland 公司的开源版数据库 Interbase6.0,是一个完全非商业化的产品,用 C 和 C++ 开发。由于与 interbase 的血缘关系,大部分 interbase 的开发工具可以直接应用到 Firebird 开发中。Firebird 使用 Mozilla Public License v.1.1 许可证发行。
FreeSql 支持 Firebird 嵌入式数据库,与 Sqlite 一样属于本地数据库,并且可靠性强于 sqlite,数据库文件不过 10兆 大小。
1、安装环境
数据库环境:Firebird (嵌入式版本)
下载地址:https://firebirdsql.org/en/server-packages/
.NET版本:.net6.0
下载地址:https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install
开发机器 :windows 10
2、创建项目
我们以 console 类型项目试验 插入、删除、更新、查询 等功能,创建控制台项目,使用命令:
dotnet new console
dotnet add package FreeSql.Provider.Firebird
dotnet add package FreeSql.Repository
3、创建实体模型
using System;
using FreeSql.DataAnnotations;
[Table(Name = "USER_FIREBIRD")]
public class User
{
[Column(IsIdentity = true)]
public long Id { get; set; }
public string UserName { get; set; }
public string PassWord { get; set; }
public DateTime CreateTime { get; set; }
}
4、初始化 ORM
static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.Firebird,
@"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=