Furion 官網(wǎng)
非常齊全且兼容性高的的一款輕量級(jí)框架
一創(chuàng)建帶有 Furion 的項(xiàng)目
//打開(kāi) CMD 或 Powershell 執(zhí)行模板安裝命令:
//dotnet new furionmvc -n 項(xiàng)目名稱
dotnet new --install Furion.Template.Mvc::2.20.3
// .NET6
dotnet new --install Furion.Template.Mvc::3.1.1
//創(chuàng)建帶有Furion框架的模板項(xiàng)目
dotnet new FurionApi -n FurionApi
以上我創(chuàng)建的三個(gè)
api (HelloBlog、 FurionApi)
mvc ( FurionMvc )
以FurionApi 為列
Furion 推薦采用多層項(xiàng)目設(shè)計(jì)架構(gòu),每一個(gè)項(xiàng)目層的依賴分別是:
FurionApi .Application:添加 FurionApi .Core 引用
FurionApi .Core:添加 Furion 引用 ??
FurionApi .Database.Migrations:添加 FurionApi .EntityFramework.Core 引用
FurionApi .EntityFramework.Core:添加 FurionApi .Core 引用
FurionApi .Web.Core:添加 FurionApi .Application,F(xiàn)urionApi .Database.Migrations 引用
FurionApi .Web.Entry:添加 FurionApi .Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools 包
運(yùn)行結(jié)果
Furion 支持ef core 、SqlSugar 等orm 框架;下面以ef core 為列,數(shù)據(jù)庫(kù)生成模型 【SqlServer 版】
①FurionApi .Web.Entry
添加 FurionApi .Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools 包
②FurionApi.Core
添加Microsoft.EntityFrameworkCore.Design包
添加Microsoft.EntityFrameworkCore.SqlServer包
第一步
須把Furion 源碼文件夾下的 tools/cli.ps1 文件拷貝到本地項(xiàng)目根目錄中 gitee 下載自己版本對(duì)應(yīng)的分支
第二步
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 存放生成的實(shí)體類
創(chuàng)建成功
創(chuàng)建成功文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-439458.html
PM> Show-Command ./tools/cli.ps1
// -----------------------------------------------------------------------------
// ______ _ _______ _
// | ____| (_) |__ __| | |
// | |__ _ _ _ __ _ ___ _ __ | | ___ ___ | |___
// | __| | | | '__| |/ _ \| '_ \ | |/ _ \ / _ \| / __|
// | | | |_| | | | | (_) | | | | | | (_) | (_) | \__ \
// |_| \__,_|_| |_|\___/|_| |_| |_|\___/ \___/|_|___/
//
// -----------------------------------------------------------------------------
Furion Tools v2.20.0 啟動(dòng)中......
Furion Tools v2.20.0 啟動(dòng)成功!
Furion Tools v2.20.0 請(qǐng)鍵入操作類型:[G] 界面操作,[任意字符] 命令行操作
Furion Tools v2.20.0 您的輸入是: G
Furion Tools v2.20.0 正在加載數(shù)據(jù)庫(kù)表和視圖......
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 開(kāi)始生成實(shí)體文件......
Furion Tools v2.20.0 正在生成 SySDepartment.cs 實(shí)體代碼......
Furion Tools v2.20.0 成功生成 SySDepartment.cs 實(shí)體代碼
// -----------------------------------------------------------------------------
// 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 實(shí)體代碼......
Furion Tools v2.20.0 成功生成 SySGlobalMultipleLanguageValue.cs 實(shí)體代碼
// -----------------------------------------------------------------------------
// 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 全部實(shí)體生成成功!
PM>
Furion框架-api模板創(chuàng)建demo文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-439458.html
到了這里,關(guān)于Furion 框架 — 讓 .NET 開(kāi)發(fā)更簡(jiǎn)單,更通用,更流行。的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!