/// <summary> /// 验证非键值生成 /// </summary> /// <param name="model">模型</param> protected virtual void ValidateNonKeyValueGeneration([NotNull] IModel model) { foreach (var property in model.GetEntityTypes() .SelectMany(t => t.GetDeclaredProperties()) .Where( p => ((OraclePropertyAnnotations)p.Oracle()).GetOracleValueGenerationStrategy(fallbackToModel: false) == OracleValueGenerationStrategy.SequenceHiLo && !p.IsKey())) { throw new InvalidOperationException( OracleStrings.NonKeyValueGeneration(property.Name, property.DeclaringEntityType.DisplayName())); } }
/// <summary> /// 验证共享列兼容性 /// </summary> /// <param name="mappedTypes">映射类型</param> /// <param name="tableName">表名</param> protected override void ValidateSharedColumnsCompatibility(IReadOnlyList <IEntityType> mappedTypes, string tableName) { base.ValidateSharedColumnsCompatibility(mappedTypes, tableName); var identityColumns = mappedTypes.SelectMany(et => et.GetDeclaredProperties()) .Where(p => p.Oracle().ValueGenerationStrategy == OracleValueGenerationStrategy.IdentityColumn) .Distinct((p1, p2) => p1.Name == p2.Name) .ToList(); if (identityColumns.Count > 1) { var sb = new StringBuilder().AppendJoin(identityColumns.Select(p => "'" + p.DeclaringEntityType.DisplayName() + "." + p.Name + "'")); throw new InvalidOperationException(OracleStrings.MultipleIdentityColumns(sb, tableName)); } }