安裝配置SqlSugarCore框架(也是更新的一套類似EFCore的ORM框架) 註冊SqlSugar相應服務 這邊藉由Singleton將服務給註冊進來 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 using SqlSugar ; var builder = WebApplication.CreateBuilder(args); builder.Services.AddCors(options => { options.AddDefaultPolicy( builder => { builder.WithOrigins( "http://localhost:9090" ).AllowAnyHeader().AllowAnyMethod(); }); }); builder.Services.AddSingleton<ISqlSugarClient>(config => { var client = new SqlSugarClient( new ConnectionConfig() { ConnectionString = builder.Configuration.GetConnectionString( "MySQLDbConn" ), DbType = DbType.MySql, IsAutoCloseConnection = true , InitKeyType = InitKeyType.Attribute }); return client; }); // Add services to the container. builder.Services.AddControllers(); // Learn more about c...