一、添加NuGet包,配置文件
- 添加SqlSugarCore包
- 添加一个控制台应用,用于DbFirst使用;添加类库,创建一个EntityMap文件夹,存放实体信息
ConnectionConfig connectionConfig = new ConnectionConfig()
{
ConnectionString = "Data Source=xxxxxxxx;Initial Catalog=SmartFactory;User ID=sa;Password=********",
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
};
SqlSugarClient sqlSugarClient = new SqlSugarClient(connectionConfig);
sqlSugarClient.DbFirst.CreateClassFile("E:\\.NET7.0\\SmartFactor.Entity\\EntityMap");
二、启动控制台,生成实体
- 将控制台应用程序设为启动项,启动项目成功后,会发现EntityMap中已经生成了对应的实体信息