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

Furion 官网
非常齐全且兼容性高的的一款轻量级框架
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第1张图片
一创建带有 Furion 的项目
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第2张图片

//打开 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 框架 — 让 .NET 开发更简单,更通用,更流行。_第3张图片

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

Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第4张图片
以上我创建的三个
api (HelloBlog、 FurionApi)
mvc ( FurionMvc )
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第5张图片
以FurionApi 为列
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第6张图片
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 框架 — 让 .NET 开发更简单,更通用,更流行。_第7张图片

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

Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第8张图片
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第9张图片
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": "*"
}

Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第10张图片

Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第11张图片
选择Models 存放生成的实体类
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第12张图片
创建成功
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第13张图片
创建成功
Furion 框架 — 让 .NET 开发更简单,更通用,更流行。_第14张图片

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, IEntityTypeBuilder, 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 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, IEntityTypeBuilder, 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 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

你可能感兴趣的:(Furion,框架,.NetCore,EF,core,c#,.netcore)