[#231] fixed schema miss
This commit is contained in:
parent
8b7cb48fd1
commit
d30f82a185
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue