public virtual ConventionSet AddConventions([NotNull] ConventionSet conventionSet) { Check.NotNull(conventionSet, nameof(conventionSet)); var mongoDatabaseAttributeConvention = new MongoDatabaseAttributeConvention(_currentDbContext.Context); PropertyDiscoveryConvention mongoDbPropertyDiscoveryConvention = new MongoDbPropertyDiscoveryConvention(); RelationshipDiscoveryConvention mongoDbRelationshipDiscoveryConvention = new MongoDbRelationshipDiscoveryConvention(); PropertyMappingValidationConvention mongoDbPropertyMappingValidationConvention = new MongoDbPropertyMappingValidationConvention(); DatabaseGeneratedAttributeConvention mongoDbDatabaseGeneratedAttributeConvention = new MongoDbDatabaseGeneratedAttributeConvention(); conventionSet.ModelInitializedConventions .With(mongoDatabaseAttributeConvention); conventionSet.EntityTypeAddedConventions .Replace(mongoDbPropertyDiscoveryConvention) .Replace(mongoDbRelationshipDiscoveryConvention) .With(new MongoDbDerivedTypeAttributeConvention()) .With(new MongoDbDiscriminatorAttributeConvention()) .With(new MongoDbRootTypeAttributeConvention()); conventionSet.BaseEntityTypeSetConventions .Replace(mongoDbPropertyDiscoveryConvention) .Replace(mongoDbRelationshipDiscoveryConvention); conventionSet.EntityTypeMemberIgnoredConventions .Replace(mongoDbRelationshipDiscoveryConvention); conventionSet.PropertyAddedConventions .Replace(mongoDbDatabaseGeneratedAttributeConvention); conventionSet.PropertyFieldChangedConventions .Replace(mongoDbDatabaseGeneratedAttributeConvention); conventionSet.NavigationAddedConventions .Replace(mongoDbRelationshipDiscoveryConvention); conventionSet.NavigationRemovedConventions .Replace(mongoDbRelationshipDiscoveryConvention); conventionSet.ModelBuiltConventions .Replace(mongoDbPropertyMappingValidationConvention); return(conventionSet); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual ConventionSet AddConventions(ConventionSet conventionSet) { Check.NotNull(conventionSet, nameof(conventionSet)); DatabaseGeneratedAttributeConvention databaseGeneratedAttributeConvention = new MongoDbDatabaseGeneratedAttributeConvention(); KeyAttributeConvention keyAttributeConvention = new MongoDbKeyAttributeConvention(); var mongoDatabaseConvention = new MongoDatabaseConvention(_mongoDbConventionSetBuilderDependencies.CurrentDbContext.Context); ModelCleanupConvention modelCleanupConvention = new MongoDbModelCleanupConvention(); conventionSet.ModelInitializedConventions .With(mongoDatabaseConvention); conventionSet.EntityTypeAddedConventions .InsertBefore <IEntityTypeAddedConvention, BaseTypeDiscoveryConvention>(new MongoDbBaseTypeDiscoveryConvention()) .With(new MongoCollectionAttributeConvention()) .With(new BsonIgnoreAttributeConvention()) .With(new BsonDiscriminatorAttributeConvention()) .With(new MongoDbRegisterKnownTypesConvention()); conventionSet.ForeignKeyOwnershipChangedConventions .Without(item => item is NavigationEagerLoadingConvention); conventionSet.ForeignKeyAddedConventions .With(new MongoDbForeignAddedConvention()); conventionSet.PropertyAddedConventions .Replace(databaseGeneratedAttributeConvention) .Replace(keyAttributeConvention); conventionSet.PropertyFieldChangedConventions .Replace(databaseGeneratedAttributeConvention) .Replace(keyAttributeConvention); conventionSet.ModelBuiltConventions .Replace(keyAttributeConvention) .Replace(modelCleanupConvention); return(conventionSet); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual ConventionSet AddConventions(ConventionSet conventionSet) { Check.NotNull(conventionSet, nameof(conventionSet)); var mongoDbRelationshipDiscoveryConvention = new MongoDbRelationshipDiscoveryConvention( _mongoDbConventionSetBuilderDependencies.MemberClassifier, _mongoDbConventionSetBuilderDependencies.ModelLogger); RelationshipDiscoveryConvention relationshipDiscoveryConvention = mongoDbRelationshipDiscoveryConvention; var ownedDocumentConvention = new OwnedDocumentConvention(); DatabaseGeneratedAttributeConvention databaseGeneratedAttributeConvention = new MongoDbDatabaseGeneratedAttributeConvention(); KeyAttributeConvention keyAttributeConvention = new MongoDbKeyAttributeConvention(); var mongoDatabaseConvention = new MongoDatabaseConvention(_mongoDbConventionSetBuilderDependencies.CurrentDbContext.Context); var bsonRequiredAttributeConvention = new BsonRequiredAttributeConvention(); PropertyMappingValidationConvention propertyMappingValidationConvention = new DocumentPropertyMappingValidationConvention( _mongoDbConventionSetBuilderDependencies.MongoDbTypeMapperSource, _mongoDbConventionSetBuilderDependencies.MemberClassifier); conventionSet.ModelInitializedConventions .With(mongoDatabaseConvention); conventionSet.EntityTypeAddedConventions .Replace(relationshipDiscoveryConvention) .With(ownedDocumentConvention) .With(new MongoCollectionAttributeConvention()) .With(new BsonDiscriminatorAttributeConvention()) .With(new BsonIgnoreAttributeConvention()) .With(new BsonKnownTypesAttributeConvention()); conventionSet.BaseEntityTypeChangedConventions .Replace(relationshipDiscoveryConvention) .With(ownedDocumentConvention); conventionSet.EntityTypeMemberIgnoredConventions .Replace(relationshipDiscoveryConvention); conventionSet.KeyAddedConventions .With(ownedDocumentConvention); conventionSet.KeyRemovedConventions .With(ownedDocumentConvention); conventionSet.ForeignKeyAddedConventions .With(ownedDocumentConvention); conventionSet.ForeignKeyOwnershipChangedConventions .With(mongoDbRelationshipDiscoveryConvention) .Without(item => item is NavigationEagerLoadingConvention); conventionSet.PropertyAddedConventions .Replace(databaseGeneratedAttributeConvention) .Replace(keyAttributeConvention) .With(bsonRequiredAttributeConvention); conventionSet.PropertyFieldChangedConventions .Replace(databaseGeneratedAttributeConvention) .Replace(keyAttributeConvention) .With(bsonRequiredAttributeConvention); conventionSet.NavigationAddedConventions .Replace(relationshipDiscoveryConvention); conventionSet.NavigationRemovedConventions .Replace(relationshipDiscoveryConvention); conventionSet.ModelBuiltConventions .Replace(keyAttributeConvention) .Replace(propertyMappingValidationConvention) .With(ownedDocumentConvention); return(conventionSet); }