- 优化 CodeFirst 字段变化对比逻辑

This commit is contained in:
28810
2020-05-26 02:50:21 +08:00
parent 1ac13d6327
commit 0d6ebc1e26
13 changed files with 199 additions and 185 deletions

View File

@ -184,9 +184,10 @@ namespace FreeSql.Sqlite
{
foreach (var tbcol in tb.ColumnsByPosition)
{
if (istmpatler) break;
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"NOT\s+NULL", "NULL");
if (tbstruct.TryGetValue(tbcol.Attribute.Name, out var tbstructcol) ||
string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
{
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
istmpatler = true;
@ -202,6 +203,9 @@ namespace FreeSql.Sqlite
//添加列
istmpatler = true;
}
}
if (istmpatler == false)
{
var dsuk = new List<string[]>();
var dbIndexes = _orm.Ado.ExecuteArray(CommandType.Text, $"PRAGMA {_commonUtils.QuoteSqlName(tbtmp[0])}.INDEX_LIST(\"{tbtmp[1]}\")");
foreach (var dbIndex in dbIndexes)