[#231] fixed schema miss
This commit is contained in:
parent
8b7cb48fd1
commit
d30f82a185
|
@ -81,6 +81,10 @@ namespace ShardingCore.Core.EntityMetadatas
|
||||||
/// 逻辑表名
|
/// 逻辑表名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string LogicTableName { get; private set; }
|
public string LogicTableName { get; private set; }
|
||||||
|
/**
|
||||||
|
* 对象表所属schema
|
||||||
|
*/
|
||||||
|
public string Schema { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主键
|
/// 主键
|
||||||
|
@ -105,6 +109,7 @@ namespace ShardingCore.Core.EntityMetadatas
|
||||||
PrimaryKeyProperties = dbEntityType.FindPrimaryKey()?.Properties?.Select(o => o.PropertyInfo)?.ToList() ??
|
PrimaryKeyProperties = dbEntityType.FindPrimaryKey()?.Properties?.Select(o => o.PropertyInfo)?.ToList() ??
|
||||||
new List<PropertyInfo>();
|
new List<PropertyInfo>();
|
||||||
IsSingleKey = PrimaryKeyProperties.Count == 1;
|
IsSingleKey = PrimaryKeyProperties.Count == 1;
|
||||||
|
Schema = dbEntityType.GetEntityTypeSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace ShardingCore.EFCores
|
||||||
var tableName = entityMetadata.LogicTableName;
|
var tableName = entityMetadata.LogicTableName;
|
||||||
if (string.IsNullOrWhiteSpace(tableName))
|
if (string.IsNullOrWhiteSpace(tableName))
|
||||||
throw new ArgumentNullException($"{shardingEntity}: not found logic table name。");
|
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
|
#endif
|
||||||
#if EFCORE2
|
#if EFCORE2
|
||||||
var tableName = entityType.Relational().TableName;
|
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
|
#endif
|
||||||
return tableName;
|
return tableName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue