修复代理模式下的bug
This commit is contained in:
parent
9485ae03c1
commit
c4069b1919
|
@ -324,7 +324,7 @@ namespace ShardingCore.Extensions
|
|||
public static TEntity GetAttachedEntity<TEntity>(this DbContext context, TEntity entity) where TEntity:class
|
||||
{
|
||||
if (entity == null) { throw new ArgumentNullException(nameof(entity)); }
|
||||
var entityPrimaryKey = context.Model.FindEntityType(entity.GetType()).FindPrimaryKey();
|
||||
var entityPrimaryKey = context.Model.FindRuntimeEntityType(entity.GetType()).FindPrimaryKey();
|
||||
if (entityPrimaryKey == null)
|
||||
{
|
||||
return entity;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.9" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
|
|
|
@ -19,6 +19,12 @@ namespace ShardingCore.Test
|
|||
{
|
||||
}
|
||||
|
||||
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
//{
|
||||
// base.OnConfiguring(optionsBuilder);
|
||||
// optionsBuilder.UseLazyLoadingProxies();
|
||||
//}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
|
Loading…
Reference in New Issue