diff --git a/Src/Asp.Net/MySqlTest/Demos/5_CodeFirst.cs b/Src/Asp.Net/MySqlTest/Demos/5_CodeFirst.cs index e56b212e5..2813aac9e 100644 --- a/Src/Asp.Net/MySqlTest/Demos/5_CodeFirst.cs +++ b/Src/Asp.Net/MySqlTest/Demos/5_CodeFirst.cs @@ -6,12 +6,13 @@ using System.Text; namespace OrmTest.Demo { + [SugarTable("CodeTable", " CodeTable test ")] public class CodeTable { - [SugarColumn(IsNullable =false ,IsPrimaryKey =true,IsIdentity =true)] + [SugarColumn(IsNullable =false ,IsPrimaryKey =true,IsIdentity =true,ColumnDescription ="test")] public int Id { get; set; } - [SugarColumn(Length = 21,OldColumnName = "Name2")] + [SugarColumn(Length = 21,OldColumnName = "Name2",ColumnDescription ="name")] public string Name{ get; set; } [SugarColumn(IsNullable = true,Length =11)] public string IsOk { get; set; } diff --git a/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs b/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs index e0d1474d6..f281c3156 100644 --- a/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs +++ b/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs @@ -17,7 +17,7 @@ namespace SqlSugar public SugarTable(string tableName,string tableDescription) { this.TableName = tableName; - this.TableDescription = tableName; + this.TableDescription = tableDescription; } } [AttributeUsage(AttributeTargets.Property , Inherited = true)] diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs index 26df6cb10..64ebcba37 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/CodeFirst/MySqlCodeFirst.cs @@ -67,5 +67,10 @@ namespace SqlSugar if (item.IsPrimarykey) this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName); } + + internal DbColumnInfo GetEntityColumnToDbColumn(EntityInfo entity, string dbTableName, EntityColumnInfo item) + { + return EntityColumnToDbColumn(entity,dbTableName,item); + } } } diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs index ee6d14e7e..6aed98c4e 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs @@ -249,6 +249,22 @@ namespace SqlSugar this.Context.Ado.ExecuteCommand(sql); return true; } + public override bool AddRemark(EntityInfo entity) + { + var db = this.Context; + db.DbMaintenance.AddTableRemark(entity.DbTableName, entity.TableDescription); + List columns = entity.Columns.Where(it => it.IsIgnore == false).ToList(); + foreach (var item in columns) + { + if (item.ColumnDescription != null) + { + var mySqlCodeFirst = this.Context.CodeFirst as MySqlCodeFirst; + string sql = GetUpdateColumnSql(entity.DbTableName, mySqlCodeFirst.GetEntityColumnToDbColumn(entity, entity.DbTableName, item))+" "+(item.IsIdentity? "AUTO_INCREMENT" : "")+" " + " COMMENT '" + item.ColumnDescription + "'"; + db.Ado.ExecuteCommand(sql); + } + } + return true; + } protected override string GetCreateTableSql(string tableName, List columns) { List columnArray = new List(); @@ -303,6 +319,7 @@ namespace SqlSugar Check.ThrowNotSupportedException("MySql BackupDataBase NotSupported"); return false; } + #endregion } }