栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

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

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/903691.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号