|
|
|
@ -67,6 +67,13 @@ namespace Volo.Abp.EntityFrameworkCore |
|
|
|
BindingFlags.Instance | BindingFlags.NonPublic |
|
|
|
); |
|
|
|
|
|
|
|
private static readonly MethodInfo ConfigureValueGeneratedMethodInfo |
|
|
|
= typeof(AbpDbContext<TDbContext>) |
|
|
|
.GetMethod( |
|
|
|
nameof(ConfigureValueGenerated), |
|
|
|
BindingFlags.Instance | BindingFlags.NonPublic |
|
|
|
); |
|
|
|
|
|
|
|
protected AbpDbContext(DbContextOptions<TDbContext> options) |
|
|
|
: base(options) |
|
|
|
{ |
|
|
|
@ -89,6 +96,10 @@ namespace Volo.Abp.EntityFrameworkCore |
|
|
|
ConfigureValueConverterMethodInfo |
|
|
|
.MakeGenericMethod(entityType.ClrType) |
|
|
|
.Invoke(this, new object[] { modelBuilder, entityType }); |
|
|
|
|
|
|
|
ConfigureValueGeneratedMethodInfo |
|
|
|
.MakeGenericMethod(entityType.ClrType) |
|
|
|
.Invoke(this, new object[] { modelBuilder, entityType }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -501,6 +512,23 @@ namespace Volo.Abp.EntityFrameworkCore |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual void ConfigureValueGenerated<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType) |
|
|
|
where TEntity : class |
|
|
|
{ |
|
|
|
if (!typeof(IEntity<Guid>).IsAssignableFrom(typeof(TEntity))) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var idPropertyBuilder = modelBuilder.Entity<TEntity>().Property(x => ((IEntity<Guid>) x).Id); |
|
|
|
if (idPropertyBuilder.Metadata.PropertyInfo.IsDefined(typeof(DatabaseGeneratedAttribute), true)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
idPropertyBuilder.ValueGeneratedNever(); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual bool ShouldFilterEntity<TEntity>(IMutableEntityType entityType) where TEntity : class |
|
|
|
{ |
|
|
|
if (typeof(IMultiTenant).IsAssignableFrom(typeof(TEntity))) |
|
|
|
|