Furion 框架 — 让 .NET 开发更简单,更通用,更流行。

Furion 官网
非常齐全且兼容性高的的一款轻量级框架
在这里插入图片描述
一创建带有 Furion 的项目
在这里插入图片描述

//打开 CMD 或 Powershell 执行模板安装命令:
//dotnet new furionmvc -n 项目名称

dotnet new --install Furion.Template.Mvc::2.20.3
// .NET6
dotnet new --install Furion.Template.Mvc::3.1.1

在这里插入图片描述

//创建带有Furion框架的模板项目
dotnet new  FurionApi -n FurionApi

在这里插入图片描述
以上我创建的三个
api (HelloBlog、 FurionApi)
mvc ( FurionMvc )
在这里插入图片描述
以FurionApi 为列
在这里插入图片描述
Furion 推荐采用多层项目设计架构,每一个项目层的依赖分别是:

FurionApi .Application:添加 FurionApi .Core 引用
FurionApi .Core:添加 Furion 引用 🎗
FurionApi .Database.Migrations:添加 FurionApi .EntityFramework.Core 引用
FurionApi .EntityFramework.Core:添加 FurionApi .Core 引用
FurionApi .Web.Core:添加 FurionApi .Application,FurionApi .Database.Migrations 引用
FurionApi .Web.Entry:添加 FurionApi .Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools 包

运行结果
在这里插入图片描述

Furion  支持ef core 、SqlSugar  等orm 框架;下面以ef core 为列,数据库生成模型 【SqlServer 版】
①FurionApi .Web.Entry   
添加 FurionApi .Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools 包
②FurionApi.Core
添加Microsoft.EntityFrameworkCore.Design包
添加Microsoft.EntityFrameworkCore.SqlServer包

第一步
须把Furion 源码文件夹下的 tools/cli.ps1 文件拷贝到本地项目根目录中 gitee 下载自己版本对应的分支

第二步

PM> Show-Command ../tools/cli.ps1

在这里插入图片描述
在这里插入图片描述
appsettings.json

{
  "ConnectionStrings": {
    //"DbConnectionString": "Server=localhost;Database=Furion;User=sa;Password=000000;MultipleActiveResultSets=True;",
    "DbConnectionString": "Server=.;database=Test_Demo;Trusted_Connection=True;MultipleActiveResultSets=True;",
    "Sqlite3ConnectionString": "Data Source=./Test_Demo.db"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information",
      "Microsoft.EntityFrameworkCore": "Information"
    }
  },
  "AllowedHosts": "*"
}

在这里插入图片描述

在这里插入图片描述
选择Models 存放生成的实体类
在这里插入图片描述
创建成功
在这里插入图片描述
创建成功
在这里插入图片描述

PM> Show-Command ./tools/cli.ps1
// -----------------------------------------------------------------------------
//  ______          _               _______          _     
// |  ____|        (_)             |__   __|        | |    
// | |__ _   _ _ __ _  ___  _ __      | | ___   ___ | |___ 
// |  __| | | | '__| |/ _ \| '_ \     | |/ _ \ / _ \| / __|
// | |  | |_| | |  | | (_) | | | |    | | (_) | (_) | \__ \
// |_|   \__,_|_|  |_|\___/|_| |_|    |_|\___/ \___/|_|___/
//                                                         
// -----------------------------------------------------------------------------
Furion Tools v2.20.0 启动中......
Furion Tools v2.20.0 启动成功!
Furion Tools v2.20.0 请键入操作类型:[G] 界面操作,[任意字符] 命令行操作
Furion Tools v2.20.0 您的输入是: G
Furion Tools v2.20.0 正在加载数据库表和视图......
Furion Tools v2.20.0 加载成功!
Furion Tools v2.20.0 正在编译解决方案代码......
Build started...
Build succeeded.
The Entity Framework tools version '5.0.12' is older than that of the runtime '5.0.15'. Update the tools for the latest features and bug fixes.
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
Furion Tools v2.20.0 编译成功!
Furion Tools v2.20.0 开始生成实体文件......
Furion Tools v2.20.0 正在生成 SySDepartment.cs 实体代码......
Furion Tools v2.20.0 成功生成 SySDepartment.cs 实体代码
// -----------------------------------------------------------------------------
// Generate By Furion Tools v2.20.0                            
// -----------------------------------------------------------------------------

using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using FurionApi.Core;

namespace FurionApi.Core
{
    public partial class SySDepartment : IEntity<MasterDbContextLocator>, IEntityTypeBuilder<SySDepartment, MasterDbContextLocator>
    {
    
        public string Facility { get; set; }
        public string Site { get; set; }
        public string DeptCode { get; set; }
        public int? LineId { get; set; }
        public string UpperDept { get; set; }
        public string Creator { get; set; }
        public DateTime CreateDate { get; set; }
        public string Modifier { get; set; }
        public DateTime? ModifyDate { get; set; }
    
        public void Configure(EntityTypeBuilder<SySDepartment> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
                entityBuilder.HasKey(e => new { e.DeptCode, e.Facility, e.Site });

                entityBuilder.ToTable("SY_S_DEPARTMENT");

                entityBuilder.Property(e => e.DeptCode)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("DEPT_CODE");

                entityBuilder.Property(e => e.Facility)
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("FACILITY");

                entityBuilder.Property(e => e.Site)
                    .HasMaxLength(15)
                    .IsUnicode(false)
                    .HasColumnName("SITE");

                entityBuilder.Property(e => e.CreateDate)
                    .HasColumnType("datetime")
                    .HasColumnName("CREATE_DATE")
                    .HasDefaultValueSql("(getdate())");

                entityBuilder.Property(e => e.Creator)
                    .IsRequired()
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("CREATOR");

                entityBuilder.Property(e => e.LineId).HasColumnName("LINE_ID");

                entityBuilder.Property(e => e.Modifier)
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("MODIFIER");

                entityBuilder.Property(e => e.ModifyDate)
                    .HasColumnType("datetime")
                    .HasColumnName("MODIFY_DATE");

                entityBuilder.Property(e => e.UpperDept)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("UPPER_DEPT");
        }

    }
}
Furion Tools v2.20.0 正在生成 SySGlobalMultipleLanguageValue.cs 实体代码......
Furion Tools v2.20.0 成功生成 SySGlobalMultipleLanguageValue.cs 实体代码
// -----------------------------------------------------------------------------
// Generate By Furion Tools v2.20.0                            
// -----------------------------------------------------------------------------

using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using FurionApi.Core;

namespace FurionApi.Core
{
    public partial class SySGlobalMultipleLanguageValue : IEntity<MasterDbContextLocator>, IEntityTypeBuilder<SySGlobalMultipleLanguageValue, MasterDbContextLocator>
    {
    
        public string LookupType { get; set; }
        public string LookupValue { get; set; }
        public string Meaning { get; set; }
        public string Language { get; set; }
        public string Creator { get; set; }
        public DateTime CreateDate { get; set; }
        public string Modifier { get; set; }
        public DateTime? ModifyDate { get; set; }
    
        public void Configure(EntityTypeBuilder<SySGlobalMultipleLanguageValue> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
                entityBuilder.HasKey(e => new { e.LookupType, e.LookupValue, e.Language })
                    .HasName("PK_SY_S_GLOBAL_TABLE_LANGUAGE_VALUE");

                entityBuilder.ToTable("SY_S_GLOBAL_MULTIPLE_LANGUAGE_VALUE");

                entityBuilder.Property(e => e.LookupType)
                    .HasMaxLength(80)
                    .IsUnicode(false)
                    .HasColumnName("LOOKUP_TYPE");

                entityBuilder.Property(e => e.LookupValue)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("LOOKUP_VALUE");

                entityBuilder.Property(e => e.Language)
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("LANGUAGE");

                entityBuilder.Property(e => e.CreateDate)
                    .HasColumnType("datetime")
                    .HasColumnName("CREATE_DATE");

                entityBuilder.Property(e => e.Creator)
                    .IsRequired()
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("CREATOR");

                entityBuilder.Property(e => e.Meaning)
                    .IsRequired()
                    .HasMaxLength(100)
                    .HasColumnName("MEANING");

                entityBuilder.Property(e => e.Modifier)
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("MODIFIER");

                entityBuilder.Property(e => e.ModifyDate)
                    .HasColumnType("datetime")
                    .HasColumnName("MODIFY_DATE");
        }

    }
}
Furion Tools v2.20.0 全部实体生成成功!
PM> 

Furion框架-api模板创建demo

  • 11
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值