SqlSugar数据库辅助类
using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MyMS { /// <summary> /// 数据库辅助类-生成实体、创建数据库对象 /// </summary> public class DBHelp { /// <summary> /// 数据库对象 /// </summary> public static SqlSugarClient db = null; /// <summary> /// 创建数据库连接对象 /// </summary> /// <returns></returns> public static void InitDB() { ConnectionConfig connectionConfig = new ConnectionConfig() { DbType = DbType.SqlServer, IsAutoCloseConnection = true, ConnectionString = "Data Source=localhost;Initial Catalog=MYMS;User Id=sa;Password=123!@#" }; db = new SqlSugarClient(connectionConfig); } /// <summary> /// 创建数据库实体 /// </summary> public static void CreateModel() { if (db != null) { db.DbFirst.IsCreateAttribute().CreateClassFile("D:\\", "Models"); } } } }