SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = configuration.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true, ConfigureExternalServices = new ConfigureExternalServices() { EntityService = (property, column) => { var attributes = property.GetCustomAttributes(true);//get all attributes
if (attributes.Any(it => it is KeyAttribute))// by attribute set primarykey { column.IsPrimarykey = true; //有哪些特性可以看 1.2 特性明细 } //可以写多个,这边可以断点调试 // if (attributes.Any(it => it is NotMappedAttribute)) //{ // column.IsIgnore= true; //} }, EntityNameService = (type, entity) => { var attributes = type.GetCustomAttributes(true); if (attributes.Any(it => it is TableAttribute)) { entity.DbTableName = (attributes.First(it => it is TableAttribute) as TableAttribute).Name; } } } });