[#231] fixed schema miss

This commit is contained in:
xuejiaming 2023-03-16 18:33:20 +08:00
parent 8b7cb48fd1
commit d30f82a185
3 changed files with 16 additions and 1 deletions

View File

@ -81,6 +81,10 @@ namespace ShardingCore.Core.EntityMetadatas
/// 逻辑表名
/// </summary>
public string LogicTableName { get; private set; }
/**
* schema
*/
public string Schema { get; private set; }
/// <summary>
/// 主键
@ -105,6 +109,7 @@ namespace ShardingCore.Core.EntityMetadatas
PrimaryKeyProperties = dbEntityType.FindPrimaryKey()?.Properties?.Select(o => o.PropertyInfo)?.ToList() ??
new List<PropertyInfo>();
IsSingleKey = PrimaryKeyProperties.Count == 1;
Schema = dbEntityType.GetEntityTypeSchema();
}

View File

@ -87,7 +87,7 @@ namespace ShardingCore.EFCores
var tableName = entityMetadata.LogicTableName;
if (string.IsNullOrWhiteSpace(tableName))
throw new ArgumentNullException($"{shardingEntity}: not found logic table name。");
entity.ToTable($"{tableName}{tableSeparator}{tail}");
entity.ToTable($"{tableName}{tableSeparator}{tail}",entityMetadata.Schema);
}
}
}

View File

@ -22,6 +22,16 @@ namespace ShardingCore.Extensions.InternalExtensions
#endif
#if EFCORE2
var tableName = entityType.Relational().TableName;
#endif
return tableName;
}
public static string GetEntityTypeSchema(this IEntityType entityType)
{
#if !EFCORE2
var tableName = entityType.GetSchema();
#endif
#if EFCORE2
var tableName = entityType.Relational().Schema;
#endif
return tableName;
}