public virtual ConventionSet AddConventions(ConventionSet conventionSet)
        {
            Check.NotNull(conventionSet, nameof(conventionSet));

            conventionSet.PropertyAddedConventions.Add(new RelationalColumnAttributeConvention());

            conventionSet.EntityTypeAddedConventions.Add(new RelationalTableAttributeConvention());

            return conventionSet;
        }
        public override ConventionSet AddConventions(ConventionSet conventionSet)
        {
            Check.NotNull(conventionSet, nameof(conventionSet));

            base.AddConventions(conventionSet);

            conventionSet.ModelInitializedConventions.Add(new SqlServerValueGenerationStrategyConvention());

            return conventionSet;
        }
        public virtual ConventionSet CreateConventionSet()
        {
            var conventionSet = new ConventionSet();

            var relationshipDiscoveryConvention = new RelationshipDiscoveryConvention();
            conventionSet.EntityTypeAddedConventions.Add(new NotMappedEntityTypeAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new NotMappedMemberAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new PropertyDiscoveryConvention());
            conventionSet.EntityTypeAddedConventions.Add(new KeyDiscoveryConvention());
            conventionSet.EntityTypeAddedConventions.Add(new InversePropertyAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(relationshipDiscoveryConvention);

            // An ambiguity might have been resolved
            conventionSet.EntityTypeMemberIgnoredConventions.Add(relationshipDiscoveryConvention);

            conventionSet.PropertyAddedConventions.Add(new ConcurrencyCheckAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new DatabaseGeneratedAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new RequiredPropertyAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new MaxLengthAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new StringLengthAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new TimestampAttributeConvention());

            var keyAttributeConvention = new KeyAttributeConvention();
            conventionSet.PropertyAddedConventions.Add(keyAttributeConvention);

            var keyConvention = new KeyConvention();
            conventionSet.KeyAddedConventions.Add(keyConvention);

            conventionSet.PrimaryKeySetConventions.Add(keyConvention);
            
            var foreignKeyPropertyDiscoveryConvention = new ForeignKeyPropertyDiscoveryConvention();
            conventionSet.ForeignKeyAddedConventions.Add(new ForeignKeyAttributeConvention());
            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.ForeignKeyRemovedConventions.Add(keyConvention);

            conventionSet.ModelBuiltConventions.Add(new ModelCleanupConvention());
            conventionSet.ModelBuiltConventions.Add(keyAttributeConvention);

            conventionSet.NavigationAddedConventions.Add(new RequiredNavigationAttributeConvention());
            conventionSet.NavigationAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            
            conventionSet.NavigationRemovedConventions.Add(relationshipDiscoveryConvention);

            return conventionSet;
        }
        public virtual ConventionSet CreateConventionSet()
        {
            var conventionSet = new ConventionSet();

            conventionSet.EntityTypeAddedConventions.Add(new NotMappedEntityTypeAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new PropertyDiscoveryConvention());
            conventionSet.EntityTypeAddedConventions.Add(new KeyDiscoveryConvention());
            conventionSet.EntityTypeAddedConventions.Add(new NotMappedNavigationAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new InversePropertyAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new RelationshipDiscoveryConvention());

            conventionSet.PropertyAddedConventions.Add(new NotMappedPropertyAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new ConcurrencyCheckAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new DatabaseGeneratedAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new RequiredPropertyAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new MaxLengthAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new StringLengthAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new TimestampAttributeConvention());

            var keyAttributeConvention = new KeyAttributeConvention();
            conventionSet.PropertyAddedConventions.Add(keyAttributeConvention);

            var keyConvention = new KeyConvention();
            conventionSet.KeyAddedConventions.Add(keyConvention);

            conventionSet.ForeignKeyAddedConventions.Add(new ForeignKeyAttributeConvention());
            conventionSet.ForeignKeyAddedConventions.Add(new ForeignKeyPropertyDiscoveryConvention());

            conventionSet.ForeignKeyRemovedConventions.Add(keyConvention);

            conventionSet.ModelBuiltConventions.Add(keyAttributeConvention);

            conventionSet.NavigationAddedConventions.Add(new RequiredNavigationAttributeConvention());

            return conventionSet;
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public ConventionDispatcher([NotNull] ConventionSet conventionSet)
 {
     _immediateConventionScope = new ImmediateConventionScope(conventionSet, this);
     _scope  = _immediateConventionScope;
     Tracker = new MetadataTracker();
 }
        /// <summary>
        ///     Builds and returns the convention set for the current database provider.
        /// </summary>
        /// <returns> The convention set for the current database provider. </returns>
        public virtual ConventionSet CreateConventionSet()
        {
            var conventionSet = new ConventionSet();

            var propertyDiscoveryConvention        = new PropertyDiscoveryConvention(Dependencies);
            var keyDiscoveryConvention             = new KeyDiscoveryConvention(Dependencies);
            var inversePropertyAttributeConvention = new InversePropertyAttributeConvention(Dependencies);
            var relationshipDiscoveryConvention    = new RelationshipDiscoveryConvention(Dependencies);
            var servicePropertyDiscoveryConvention = new ServicePropertyDiscoveryConvention(Dependencies);
            var indexAttributeConvention           = new IndexAttributeConvention(Dependencies);

            conventionSet.EntityTypeAddedConventions.Add(new NotMappedEntityTypeAttributeConvention(Dependencies));
            conventionSet.EntityTypeAddedConventions.Add(new OwnedEntityTypeAttributeConvention(Dependencies));
            conventionSet.EntityTypeAddedConventions.Add(new KeylessEntityTypeAttributeConvention(Dependencies));
            conventionSet.EntityTypeAddedConventions.Add(new NotMappedMemberAttributeConvention(Dependencies));
            conventionSet.EntityTypeAddedConventions.Add(new BaseTypeDiscoveryConvention(Dependencies));
            conventionSet.EntityTypeAddedConventions.Add(propertyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(servicePropertyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(indexAttributeConvention);
            conventionSet.EntityTypeAddedConventions.Add(inversePropertyAttributeConvention);
            conventionSet.EntityTypeAddedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(new DerivedTypeDiscoveryConvention(Dependencies));

            conventionSet.EntityTypeIgnoredConventions.Add(inversePropertyAttributeConvention);
            conventionSet.EntityTypeIgnoredConventions.Add(relationshipDiscoveryConvention);

            var discriminatorConvention = new DiscriminatorConvention(Dependencies);

            conventionSet.EntityTypeRemovedConventions.Add(new OwnedTypesConvention(Dependencies));
            conventionSet.EntityTypeRemovedConventions.Add(discriminatorConvention);

            var foreignKeyIndexConvention = new ForeignKeyIndexConvention(Dependencies);
            var valueGeneratorConvention  = new ValueGenerationConvention(Dependencies);

            conventionSet.EntityTypeBaseTypeChangedConventions.Add(propertyDiscoveryConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(servicePropertyDiscoveryConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(keyDiscoveryConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(indexAttributeConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(inversePropertyAttributeConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(foreignKeyIndexConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(valueGeneratorConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(discriminatorConvention);

            var foreignKeyPropertyDiscoveryConvention = new ForeignKeyPropertyDiscoveryConvention(Dependencies);

            conventionSet.EntityTypeMemberIgnoredConventions.Add(inversePropertyAttributeConvention);
            conventionSet.EntityTypeMemberIgnoredConventions.Add(relationshipDiscoveryConvention);
            conventionSet.EntityTypeMemberIgnoredConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.EntityTypeMemberIgnoredConventions.Add(servicePropertyDiscoveryConvention);

            var keyAttributeConvention = new KeyAttributeConvention(Dependencies);
            var backingFieldConvention = new BackingFieldConvention(Dependencies);
            var concurrencyCheckAttributeConvention    = new ConcurrencyCheckAttributeConvention(Dependencies);
            var databaseGeneratedAttributeConvention   = new DatabaseGeneratedAttributeConvention(Dependencies);
            var requiredPropertyAttributeConvention    = new RequiredPropertyAttributeConvention(Dependencies);
            var nonNullableReferencePropertyConvention = new NonNullableReferencePropertyConvention(Dependencies);
            var nonNullableNavigationConvention        = new NonNullableNavigationConvention(Dependencies);
            var maxLengthAttributeConvention           = new MaxLengthAttributeConvention(Dependencies);
            var stringLengthAttributeConvention        = new StringLengthAttributeConvention(Dependencies);
            var timestampAttributeConvention           = new TimestampAttributeConvention(Dependencies);
            var backingFieldAttributeConvention        = new BackingFieldAttributeConvention(Dependencies);

            conventionSet.PropertyAddedConventions.Add(backingFieldConvention);
            conventionSet.PropertyAddedConventions.Add(concurrencyCheckAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(databaseGeneratedAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(requiredPropertyAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(nonNullableReferencePropertyConvention);
            conventionSet.PropertyAddedConventions.Add(maxLengthAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(stringLengthAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(timestampAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(backingFieldAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(keyAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.PropertyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.EntityTypePrimaryKeyChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.EntityTypePrimaryKeyChangedConventions.Add(valueGeneratorConvention);

            conventionSet.KeyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.KeyAddedConventions.Add(foreignKeyIndexConvention);

            conventionSet.KeyRemovedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.KeyRemovedConventions.Add(foreignKeyIndexConvention);
            conventionSet.KeyRemovedConventions.Add(keyDiscoveryConvention);

            var cascadeDeleteConvention       = new CascadeDeleteConvention(Dependencies);
            var foreignKeyAttributeConvention = new ForeignKeyAttributeConvention(Dependencies);

            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyAttributeConvention);
            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ForeignKeyAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyAddedConventions.Add(valueGeneratorConvention);
            conventionSet.ForeignKeyAddedConventions.Add(cascadeDeleteConvention);
            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyRemovedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyRemovedConventions.Add(valueGeneratorConvention);
            conventionSet.ForeignKeyRemovedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyPropertiesChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ForeignKeyPropertiesChangedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyPropertiesChangedConventions.Add(valueGeneratorConvention);
            conventionSet.ForeignKeyPropertiesChangedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyUniquenessChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ForeignKeyUniquenessChangedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyUniquenessChangedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyRequirednessChangedConventions.Add(cascadeDeleteConvention);
            conventionSet.ForeignKeyRequirednessChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.ForeignKeyOwnershipChangedConventions.Add(new NavigationEagerLoadingConvention(Dependencies));
            conventionSet.ForeignKeyOwnershipChangedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyOwnershipChangedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.ForeignKeyOwnershipChangedConventions.Add(valueGeneratorConvention);

            conventionSet.ModelInitializedConventions.Add(new DbSetFindingConvention(Dependencies));

            conventionSet.ModelFinalizingConventions.Add(new ModelCleanupConvention(Dependencies));
            conventionSet.ModelFinalizingConventions.Add(keyAttributeConvention);
            conventionSet.ModelFinalizingConventions.Add(indexAttributeConvention);
            conventionSet.ModelFinalizingConventions.Add(foreignKeyAttributeConvention);
            conventionSet.ModelFinalizingConventions.Add(new ChangeTrackingStrategyConvention(Dependencies));
            conventionSet.ModelFinalizingConventions.Add(new ConstructorBindingConvention(Dependencies));
            conventionSet.ModelFinalizingConventions.Add(new TypeMappingConvention(Dependencies));
            conventionSet.ModelFinalizingConventions.Add(foreignKeyIndexConvention);
            conventionSet.ModelFinalizingConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ModelFinalizingConventions.Add(servicePropertyDiscoveryConvention);
            conventionSet.ModelFinalizingConventions.Add(nonNullableReferencePropertyConvention);
            conventionSet.ModelFinalizingConventions.Add(nonNullableNavigationConvention);
            conventionSet.ModelFinalizingConventions.Add(new QueryFilterDefiningQueryRewritingConvention(Dependencies));
            conventionSet.ModelFinalizingConventions.Add(inversePropertyAttributeConvention);
            conventionSet.ModelFinalizingConventions.Add(backingFieldConvention);

            conventionSet.ModelFinalizedConventions.Add(new ValidatingConvention(Dependencies));

            conventionSet.NavigationAddedConventions.Add(backingFieldConvention);
            conventionSet.NavigationAddedConventions.Add(new NavigationBackingFieldAttributeConvention(Dependencies));
            conventionSet.NavigationAddedConventions.Add(new RequiredNavigationAttributeConvention(Dependencies));
            conventionSet.NavigationAddedConventions.Add(nonNullableNavigationConvention);
            conventionSet.NavigationAddedConventions.Add(inversePropertyAttributeConvention);
            conventionSet.NavigationAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.NavigationAddedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.NavigationAddedConventions.Add(foreignKeyAttributeConvention);

            conventionSet.SkipNavigationAddedConventions.Add(backingFieldConvention);

            conventionSet.NavigationRemovedConventions.Add(relationshipDiscoveryConvention);

            conventionSet.SkipNavigationAddedConventions.Add(new ManyToManyAssociationEntityTypeConvention(Dependencies));

            conventionSet.IndexAddedConventions.Add(foreignKeyIndexConvention);

            conventionSet.IndexRemovedConventions.Add(foreignKeyIndexConvention);

            conventionSet.IndexUniquenessChangedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyPrincipalEndChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.PropertyNullabilityChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.PropertyFieldChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.PropertyFieldChangedConventions.Add(keyAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(concurrencyCheckAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(databaseGeneratedAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(requiredPropertyAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(nonNullableReferencePropertyConvention);
            conventionSet.PropertyFieldChangedConventions.Add(maxLengthAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(stringLengthAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(timestampAttributeConvention);

            return(conventionSet);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ModelBuilder" /> class that will
        ///     apply a set of conventions.
        /// </summary>
        /// <param name="conventions"> The conventions to be applied to the model. </param>
        public ModelBuilder([NotNull] ConventionSet conventions)
        {
            Check.NotNull(conventions, nameof(conventions));

            _builder = new InternalModelBuilder(new Model(conventions));
        }
Ejemplo n.º 8
0
        /// <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 CreateConventionSet()
        {
            var conventionSet = new ConventionSet();

            var propertyDiscoveryConvention
                = new PropertyDiscoveryConvention(
                      Dependencies.TypeMappingSource);

            var keyDiscoveryConvention
                = new KeyDiscoveryConvention(Dependencies.Logger);

            var inversePropertyAttributeConvention
                = new InversePropertyAttributeConvention(
                      Dependencies.TypeMappingSource,
                      Dependencies.ParameterBindingFactories,
                      Dependencies.Logger);

            var relationshipDiscoveryConvention
                = new RelationshipDiscoveryConvention(
                      Dependencies.TypeMappingSource,
                      Dependencies.ParameterBindingFactories,
                      Dependencies.Logger);

            var servicePropertyDiscoveryConvention
                = new ServicePropertyDiscoveryConvention(
                      Dependencies.TypeMappingSource,
                      Dependencies.ParameterBindingFactories);

            conventionSet.EntityTypeAddedConventions.Add(new NotMappedEntityTypeAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new OwnedEntityTypeAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new NotMappedMemberAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new BaseTypeDiscoveryConvention());
            conventionSet.EntityTypeAddedConventions.Add(propertyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(servicePropertyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(inversePropertyAttributeConvention);
            conventionSet.EntityTypeAddedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(new DerivedTypeDiscoveryConvention());

            conventionSet.EntityTypeIgnoredConventions.Add(inversePropertyAttributeConvention);

            var foreignKeyIndexConvention = new ForeignKeyIndexConvention(Dependencies.Logger);
            var valueGeneratorConvention  = new ValueGeneratorConvention();

            conventionSet.BaseEntityTypeChangedConventions.Add(propertyDiscoveryConvention);
            conventionSet.BaseEntityTypeChangedConventions.Add(servicePropertyDiscoveryConvention);
            conventionSet.BaseEntityTypeChangedConventions.Add(keyDiscoveryConvention);
            conventionSet.BaseEntityTypeChangedConventions.Add(inversePropertyAttributeConvention);
            conventionSet.BaseEntityTypeChangedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.BaseEntityTypeChangedConventions.Add(foreignKeyIndexConvention);
            conventionSet.BaseEntityTypeChangedConventions.Add(valueGeneratorConvention);

            var foreignKeyPropertyDiscoveryConvention = new ForeignKeyPropertyDiscoveryConvention(Dependencies.Logger);

            conventionSet.EntityTypeMemberIgnoredConventions.Add(inversePropertyAttributeConvention);
            conventionSet.EntityTypeMemberIgnoredConventions.Add(relationshipDiscoveryConvention);
            conventionSet.EntityTypeMemberIgnoredConventions.Add(foreignKeyPropertyDiscoveryConvention);

            var keyAttributeConvention = new KeyAttributeConvention();
            var backingFieldConvention = new BackingFieldConvention();
            var concurrencyCheckAttributeConvention  = new ConcurrencyCheckAttributeConvention();
            var databaseGeneratedAttributeConvention = new DatabaseGeneratedAttributeConvention();
            var requiredPropertyAttributeConvention  = new RequiredPropertyAttributeConvention();
            var maxLengthAttributeConvention         = new MaxLengthAttributeConvention();
            var stringLengthAttributeConvention      = new StringLengthAttributeConvention();
            var timestampAttributeConvention         = new TimestampAttributeConvention();

            conventionSet.PropertyAddedConventions.Add(backingFieldConvention);
            conventionSet.PropertyAddedConventions.Add(concurrencyCheckAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(databaseGeneratedAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(requiredPropertyAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(maxLengthAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(stringLengthAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(timestampAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.PropertyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.PropertyAddedConventions.Add(keyAttributeConvention);

            conventionSet.PrimaryKeyChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.PrimaryKeyChangedConventions.Add(valueGeneratorConvention);

            conventionSet.KeyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.KeyAddedConventions.Add(foreignKeyIndexConvention);

            conventionSet.KeyRemovedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.KeyRemovedConventions.Add(foreignKeyIndexConvention);
            conventionSet.KeyRemovedConventions.Add(keyDiscoveryConvention);

            var cascadeDeleteConvention = new CascadeDeleteConvention();

            conventionSet.ForeignKeyAddedConventions.Add(
                new ForeignKeyAttributeConvention(
                    Dependencies.TypeMappingSource,
                    Dependencies.ParameterBindingFactories,
                    Dependencies.Logger));

            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ForeignKeyAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyAddedConventions.Add(valueGeneratorConvention);
            conventionSet.ForeignKeyAddedConventions.Add(cascadeDeleteConvention);
            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyRemovedConventions.Add(keyDiscoveryConvention);
            conventionSet.ForeignKeyRemovedConventions.Add(valueGeneratorConvention);
            conventionSet.ForeignKeyRemovedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyUniquenessChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ForeignKeyUniquenessChangedConventions.Add(foreignKeyIndexConvention);

            conventionSet.ForeignKeyOwnershipChangedConventions.Add(new NavigationEagerLoadingConvention());

            conventionSet.ModelBuiltConventions.Add(new ModelCleanupConvention());
            conventionSet.ModelBuiltConventions.Add(keyAttributeConvention);
            conventionSet.ModelBuiltConventions.Add(new ChangeTrackingStrategyConvention());
            conventionSet.ModelBuiltConventions.Add(new ConstructorBindingConvention(Dependencies.ConstructorBindingFactory));
            conventionSet.ModelBuiltConventions.Add(new TypeMappingConvention(Dependencies.TypeMappingSource));
            conventionSet.ModelBuiltConventions.Add(new IgnoredMembersValidationConvention());

            conventionSet.ModelBuiltConventions.Add(
                new PropertyMappingValidationConvention(
                    Dependencies.TypeMappingSource,
                    Dependencies.ParameterBindingFactories));

            conventionSet.ModelBuiltConventions.Add(new RelationshipValidationConvention());
            conventionSet.ModelBuiltConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.NavigationAddedConventions.Add(backingFieldConvention);
            conventionSet.NavigationAddedConventions.Add(new RequiredNavigationAttributeConvention(Dependencies.Logger));
            conventionSet.NavigationAddedConventions.Add(inversePropertyAttributeConvention);
            conventionSet.NavigationAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.NavigationAddedConventions.Add(relationshipDiscoveryConvention);

            conventionSet.NavigationRemovedConventions.Add(relationshipDiscoveryConvention);

            conventionSet.IndexAddedConventions.Add(foreignKeyIndexConvention);

            conventionSet.IndexRemovedConventions.Add(foreignKeyIndexConvention);

            conventionSet.IndexUniquenessChangedConventions.Add(foreignKeyIndexConvention);

            conventionSet.PropertyNullabilityChangedConventions.Add(cascadeDeleteConvention);

            conventionSet.PrincipalEndChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.PropertyFieldChangedConventions.Add(keyDiscoveryConvention);
            conventionSet.PropertyFieldChangedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.PropertyFieldChangedConventions.Add(keyAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(concurrencyCheckAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(databaseGeneratedAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(requiredPropertyAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(maxLengthAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(stringLengthAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(timestampAttributeConvention);

            return(conventionSet);
        }
Ejemplo n.º 9
0
 public BorlandModelBuilder([NotNull] ConventionSet conventions, [NotNull] DbContext context)
     : base(conventions)
 {
     Instance = new InternalModelBuilder(new BorlandModel(conventions, context));
 }
Ejemplo n.º 10
0
 public ImmediateConventionScope([NotNull] ConventionSet conventionSet)
     : base(parent: null)
 {
     _conventionSet = conventionSet;
     MakeReadonly();
 }
 /// <summary>
 ///     <para>
 ///         Call this method to build a <see cref="ConventionSet" /> for the in-memory provider when using
 ///         the <see cref="ModelBuilder" /> outside of <see cref="DbContext.OnModelCreating" />.
 ///     </para>
 ///     <para>
 ///         Note that it is unusual to use this method.
 ///         Consider using <see cref="DbContext" /> in the normal way instead.
 ///     </para>
 /// </summary>
 /// <returns>The convention set.</returns>
 public static ConventionSet Build()
 {
     using var serviceScope = CreateServiceScope();
     using var context      = serviceScope.ServiceProvider.GetRequiredService <DbContext>();
     return(ConventionSet.CreateConventionSet(context));
 }
        /// <summary>
        ///     Builds and returns the convention set for the current database provider.
        /// </summary>
        /// <returns> The convention set for the current database provider. </returns>
        public override ConventionSet CreateConventionSet()
        {
            var conventionSet = base.CreateConventionSet();

            var relationalColumnAttributeConvention  = new RelationalColumnAttributeConvention(Dependencies, RelationalDependencies);
            var relationalCommentAttributeConvention = new RelationalColumnCommentAttributeConvention(Dependencies, RelationalDependencies);

            conventionSet.PropertyAddedConventions.Add(relationalColumnAttributeConvention);
            conventionSet.PropertyAddedConventions.Add(relationalCommentAttributeConvention);

            var tableNameFromDbSetConvention = new TableNameFromDbSetConvention(Dependencies, RelationalDependencies);

            conventionSet.EntityTypeAddedConventions.Add(new RelationalTableAttributeConvention(Dependencies, RelationalDependencies));
            conventionSet.EntityTypeAddedConventions.Add(
                new RelationalTableCommentAttributeConvention(Dependencies, RelationalDependencies));
            conventionSet.EntityTypeAddedConventions.Add(tableNameFromDbSetConvention);

            ValueGenerationConvention valueGenerationConvention =
                new RelationalValueGenerationConvention(Dependencies, RelationalDependencies);

            ReplaceConvention(conventionSet.EntityTypeBaseTypeChangedConventions, valueGenerationConvention);
            conventionSet.EntityTypeBaseTypeChangedConventions.Add(tableNameFromDbSetConvention);

            conventionSet.EntityTypeAnnotationChangedConventions.Add((RelationalValueGenerationConvention)valueGenerationConvention);

            ReplaceConvention(conventionSet.EntityTypePrimaryKeyChangedConventions, valueGenerationConvention);

            ReplaceConvention(conventionSet.ForeignKeyAddedConventions, valueGenerationConvention);
            ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGenerationConvention);

            conventionSet.PropertyFieldChangedConventions.Add(relationalColumnAttributeConvention);
            conventionSet.PropertyFieldChangedConventions.Add(relationalCommentAttributeConvention);

            var storeGenerationConvention = new StoreGenerationConvention(Dependencies, RelationalDependencies);

            conventionSet.PropertyAnnotationChangedConventions.Add(storeGenerationConvention);
            conventionSet.PropertyAnnotationChangedConventions.Add((RelationalValueGenerationConvention)valueGenerationConvention);

            var dbFunctionAttributeConvention = new RelationalDbFunctionAttributeConvention(Dependencies, RelationalDependencies);

            conventionSet.ModelInitializedConventions.Add(dbFunctionAttributeConvention);

            // ModelCleanupConvention would remove the entity types added by TableValuedDbFunctionConvention #15898
            ConventionSet.AddAfter(
                conventionSet.ModelFinalizingConventions,
                new TableValuedDbFunctionConvention(Dependencies, RelationalDependencies),
                typeof(ModelCleanupConvention));
            conventionSet.ModelFinalizingConventions.Add(new TableSharingConcurrencyTokenConvention(Dependencies, RelationalDependencies));
            conventionSet.ModelFinalizingConventions.Add(dbFunctionAttributeConvention);
            conventionSet.ModelFinalizingConventions.Add(tableNameFromDbSetConvention);
            conventionSet.ModelFinalizingConventions.Add(storeGenerationConvention);
            conventionSet.ModelFinalizingConventions.Add(new EntityTypeHierarchyMappingConvention(Dependencies, RelationalDependencies));
            conventionSet.ModelFinalizingConventions.Add(new SequenceUniquificationConvention(Dependencies, RelationalDependencies));
            conventionSet.ModelFinalizingConventions.Add(new SharedTableConvention(Dependencies, RelationalDependencies));
            ReplaceConvention(
                conventionSet.ModelFinalizingConventions,
                (QueryFilterRewritingConvention) new RelationalQueryFilterRewritingConvention(
                    Dependencies, RelationalDependencies));

            ReplaceConvention(
                conventionSet.ModelFinalizedConventions,
                (RuntimeModelConvention) new RelationalRuntimeModelConvention(Dependencies, RelationalDependencies));

            return(conventionSet);
        }
        public ConventionDispatcher([NotNull] ConventionSet conventionSet)
        {
            Check.NotNull(conventionSet, nameof(conventionSet));

            _conventionSet = conventionSet;
        }
Ejemplo n.º 14
0
        public void OnNavigationAdded_calls_apply_on_conventions_in_order(bool useBuilder)
        {
            var conventions = new ConventionSet();

            InternalRelationshipBuilder relationshipBuilder = null;
            var orderIgnored        = false;
            var orderDetailsIgnored = false;
            var convention          = new Mock <INavigationConvention>();

            convention.Setup(c => c.Apply(It.IsAny <InternalRelationshipBuilder>(), It.IsAny <Navigation>())).Returns((InternalRelationshipBuilder b, Navigation n) =>
            {
                Assert.NotNull(b);
                relationshipBuilder = new InternalRelationshipBuilder(b.Metadata, b.ModelBuilder);
                return(relationshipBuilder);
            });
            conventions.NavigationAddedConventions.Add(convention.Object);

            var nullConvention = new Mock <INavigationConvention>();

            nullConvention.Setup(c => c.Apply(It.IsAny <InternalRelationshipBuilder>(), It.IsAny <Navigation>())).Returns((InternalRelationshipBuilder b, Navigation n) =>
            {
                Assert.Same(relationshipBuilder, b);
                if (n.Name == "Order")
                {
                    orderIgnored = true;
                }
                if (n.Name == "OrderDetails")
                {
                    orderDetailsIgnored = true;
                }
                return(null);
            });
            conventions.NavigationAddedConventions.Add(nullConvention.Object);

            var extraConvention = new Mock <INavigationConvention>();

            extraConvention.Setup(c => c.Apply(It.IsAny <InternalRelationshipBuilder>(), It.IsAny <Navigation>())).Returns((InternalRelationshipBuilder b, Navigation n) =>
            {
                Assert.False(true);
                return(null);
            });
            conventions.NavigationAddedConventions.Add(extraConvention.Object);

            var builder = new InternalModelBuilder(new Model(conventions));

            var principalEntityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention);
            var dependentEntityBuilder = builder.Entity(typeof(OrderDetails), ConfigurationSource.Convention);

            if (useBuilder)
            {
                Assert.Null(dependentEntityBuilder.Relationship(principalEntityBuilder, OrderDetails.OrderProperty, Order.OrderDetailsProperty, ConfigurationSource.Convention));
            }
            else
            {
                var fk = dependentEntityBuilder.Relationship(principalEntityBuilder, ConfigurationSource.Convention)
                         .IsUnique(true, ConfigurationSource.Convention)
                         .Metadata;
                Assert.Null(fk.HasDependentToPrincipal(OrderDetails.OrderProperty));
            }

            Assert.True(orderIgnored);
            Assert.False(orderDetailsIgnored);
            Assert.NotNull(relationshipBuilder);
        }
Ejemplo n.º 15
0
        public void OnPropertyNullableChanged_calls_apply_on_conventions_in_order(bool useBuilder)
        {
            var conventions = new ConventionSet();

            var convention1 = new PropertyNullableConvention(false);
            var convention2 = new PropertyNullableConvention(true);
            var convention3 = new PropertyNullableConvention(false);

            conventions.PropertyNullableChangedConventions.Add(convention1);
            conventions.PropertyNullableChangedConventions.Add(convention2);
            conventions.PropertyNullableChangedConventions.Add(convention3);

            var builder = new ModelBuilder(conventions);

            var propertyBuilder = builder.Entity <Order>().Property(e => e.Name);

            if (useBuilder)
            {
                propertyBuilder.IsRequired();
            }
            else
            {
                propertyBuilder.Metadata.IsNullable = false;
            }

            Assert.Equal(new bool?[] { false }, convention1.Calls);
            Assert.Equal(new bool?[] { false }, convention2.Calls);
            Assert.Empty(convention3.Calls);

            propertyBuilder = builder.Entity <Order>().Property(e => e.Name);
            if (useBuilder)
            {
                propertyBuilder.IsRequired(false);
            }
            else
            {
                propertyBuilder.Metadata.IsNullable = true;
            }

            Assert.Equal(new bool?[] { false, true }, convention1.Calls);
            Assert.Equal(new bool?[] { false, true }, convention2.Calls);
            Assert.Empty(convention3.Calls);

            propertyBuilder = builder.Entity <Order>().Property(e => e.Name);
            if (useBuilder)
            {
                propertyBuilder.IsRequired(false);
            }
            else
            {
                propertyBuilder.Metadata.IsNullable = true;
            }

            Assert.Equal(new bool?[] { false, true }, convention1.Calls);
            Assert.Equal(new bool?[] { false, true }, convention2.Calls);
            Assert.Empty(convention3.Calls);

            propertyBuilder = builder.Entity <Order>().Property(e => e.Name);
            if (useBuilder)
            {
                propertyBuilder.IsRequired();
            }
            else
            {
                propertyBuilder.Metadata.IsNullable = false;
            }

            Assert.Equal(new bool?[] { false, true, false }, convention1.Calls);
            Assert.Equal(new bool?[] { false, true, false }, convention2.Calls);
            Assert.Empty(convention3.Calls);
        }
Ejemplo n.º 16
0
 public TestModelConfigurationBuilder(ConventionSet conventions)
     : base(conventions)
 {
     Conventions = conventions;
 }
Ejemplo n.º 17
0
        public virtual ConventionSet CreateConventionSet()
        {
            var conventionSet = new ConventionSet();

            var propertyDiscoveryConvention     = new PropertyDiscoveryConvention();
            var keyDiscoveryConvention          = new KeyDiscoveryConvention();
            var relationshipDiscoveryConvention = new RelationshipDiscoveryConvention();

            conventionSet.EntityTypeAddedConventions.Add(new NotMappedEntityTypeAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new NotMappedMemberAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(new BaseTypeDiscoveryConvention());
            conventionSet.EntityTypeAddedConventions.Add(propertyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(new InversePropertyAttributeConvention());
            conventionSet.EntityTypeAddedConventions.Add(relationshipDiscoveryConvention);
            conventionSet.EntityTypeAddedConventions.Add(new DerivedTypeDiscoveryConvention());

            conventionSet.BaseEntityTypeSetConventions.Add(propertyDiscoveryConvention);
            conventionSet.BaseEntityTypeSetConventions.Add(keyDiscoveryConvention);
            conventionSet.BaseEntityTypeSetConventions.Add(relationshipDiscoveryConvention);

            // An ambiguity might have been resolved
            conventionSet.EntityTypeMemberIgnoredConventions.Add(relationshipDiscoveryConvention);

            var keyAttributeConvention = new KeyAttributeConvention();
            var foreignKeyPropertyDiscoveryConvention = new ForeignKeyPropertyDiscoveryConvention();

            conventionSet.PropertyAddedConventions.Add(new ConcurrencyCheckAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new DatabaseGeneratedAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new RequiredPropertyAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new MaxLengthAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new StringLengthAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(new TimestampAttributeConvention());
            conventionSet.PropertyAddedConventions.Add(keyDiscoveryConvention);
            conventionSet.PropertyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.PropertyAddedConventions.Add(keyAttributeConvention);

            var keyConvention = new KeyConvention();

            conventionSet.KeyAddedConventions.Add(keyConvention);

            conventionSet.PrimaryKeySetConventions.Add(keyConvention);

            var cascadeDeleteConvention = new CascadeDeleteConvention();

            conventionSet.ForeignKeyAddedConventions.Add(new ForeignKeyAttributeConvention());
            conventionSet.ForeignKeyAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);
            conventionSet.ForeignKeyAddedConventions.Add(keyConvention);
            conventionSet.ForeignKeyAddedConventions.Add(cascadeDeleteConvention);

            conventionSet.ForeignKeyRemovedConventions.Add(keyConvention);

            conventionSet.ModelBuiltConventions.Add(new ModelCleanupConvention());
            conventionSet.ModelBuiltConventions.Add(keyAttributeConvention);
            conventionSet.ModelBuiltConventions.Add(new PropertyMappingValidationConvention());

            conventionSet.NavigationAddedConventions.Add(new RequiredNavigationAttributeConvention());
            conventionSet.NavigationAddedConventions.Add(foreignKeyPropertyDiscoveryConvention);

            conventionSet.NavigationRemovedConventions.Add(relationshipDiscoveryConvention);

            conventionSet.PropertyNullableChangedConventions.Add(cascadeDeleteConvention);

            return(conventionSet);
        }
 /// <summary>
 ///     <para>
 ///         Call this method to build a <see cref="ModelBuilder" /> for SQLite outside of <see cref="DbContext.OnModelCreating" />.
 ///     </para>
 ///     <para>
 ///         Note that it is unusual to use this method.
 ///         Consider using <see cref="DbContext" /> in the normal way instead.
 ///     </para>
 /// </summary>
 /// <returns>The convention set.</returns>
 public static ModelBuilder CreateModelBuilder()
 {
     using var serviceScope = CreateServiceScope();
     using var context      = serviceScope.ServiceProvider.GetRequiredService <DbContext>();
     return(new ModelBuilder(ConventionSet.CreateConventionSet(context), context.GetService <ModelDependencies>()));
 }
 protected virtual bool ReplaceConvention <TConvention, TImplementation>(
     [NotNull] IList <TConvention> conventionsList,
     [NotNull] TImplementation newConvention)
     where TImplementation : TConvention
 => ConventionSet.Replace(conventionsList, newConvention);
Ejemplo n.º 20
0
 public Model([NotNull] ConventionSet conventions)
 {
     ConventionDispatcher = new ConventionDispatcher(conventions);
     Builder = new InternalModelBuilder(this);
     ConventionDispatcher.OnModelInitialized(Builder);
 }
Ejemplo n.º 21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ModelBuilder" /> class that will
 ///     apply a set of conventions.
 /// </summary>
 /// <param name="conventions"> The conventions to be applied to the model. </param>
 public ModelBuilder(ConventionSet conventions)
     : this(conventions, null, null)
 {
 }
Ejemplo n.º 22
0
 /// <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) => conventionSet;
Ejemplo n.º 23
0
        public ConventionDispatcher([NotNull] ConventionSet conventionSet)
        {
            Check.NotNull(conventionSet, nameof(conventionSet));

            _conventionSet = conventionSet;
        }
Ejemplo n.º 24
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ModelBuilder" /> class that will
 ///     apply a set of conventions.
 /// </summary>
 /// <param name="conventions"> The conventions to be applied to the model. </param>
 /// <param name="modelDependencies"> The dependencies object for the model. </param>
 public ModelBuilder(ConventionSet conventions, ModelDependencies modelDependencies)
     : this(conventions, modelDependencies, null)
 {
     Check.NotNull(modelDependencies, nameof(modelDependencies));
 }
Ejemplo n.º 25
0
 public void Configure(ConventionSet options)
 => options.PropertyAddedConventions.Add(this);
Ejemplo n.º 26
0
        public void Migrations_compile()
        {
            var codeHelper = new CSharpHelper();
            var generator  = new CSharpMigrationGenerator(
                codeHelper,
                new CSharpMigrationOperationGenerator(codeHelper),
                new CSharpModelGenerator(codeHelper));

            var migrationCode = generator.Generate(
                "MyNamespace",
                "MyMigration",
                new MigrationOperation[0],
                new MigrationOperation[0]);

            Assert.Equal(
                @"using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Builders;
using Microsoft.Data.Entity.Migrations.Operations;

namespace MyNamespace
{
    public partial class MyMigration : Migration
    {
        public override void Up(MigrationBuilder migration)
        {
        }

        public override void Down(MigrationBuilder migration)
        {
        }
    }
}
",
                migrationCode);

            var migrationMetadataCode = generator.GenerateMetadata(
                "MyNamespace",
                typeof(MyContext),
                "MyMigration",
                "20150511161616_MyMigration",
                "7.0.0",
                new Model());

            Assert.Equal(
                @"using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations.Infrastructure;
using Microsoft.Data.Entity.Commands.Migrations;

namespace MyNamespace
{
    [ContextType(typeof(CodeCompilationTest.MyContext))]
    partial class MyMigration
    {
        public override string Id
        {
            get { return ""20150511161616_MyMigration""; }
        }

        public override string ProductVersion
        {
            get { return ""7.0.0""; }
        }

        public override void BuildTargetModel(ModelBuilder builder)
        {
        }
    }
}
",
                migrationMetadataCode);

            var build = new BuildSource
            {
                References =
                {
                    BuildReference.ByName(typeof(CodeCompilationTest).Assembly.GetName().Name),
                    BuildReference.ByName("System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"),
                    BuildReference.ByName("EntityFramework.Core"),
                    BuildReference.ByName("EntityFramework.Relational")
                },
                Sources = { migrationCode, migrationMetadataCode }
            };

            var assembly = build.BuildInMemory();

            var migrationType = assembly.GetType("MyNamespace.MyMigration", throwOnError: true);

            var contextTypeAttribute = migrationType.GetCustomAttribute <ContextTypeAttribute>();

            Assert.NotNull(contextTypeAttribute);
            Assert.Equal(typeof(MyContext), contextTypeAttribute.ContextType);

            var migration = (Migration)Activator.CreateInstance(migrationType);

            Assert.Equal("20150511161616_MyMigration", migration.Id);
            Assert.Equal("7.0.0", migration.ProductVersion);

            var migrationBuilder = new MigrationBuilder();

            migration.Up(migrationBuilder);
            Assert.Empty(migrationBuilder.Operations);

            migrationBuilder = new MigrationBuilder();
            migration.Down(migrationBuilder);
            Assert.Empty(migrationBuilder.Operations);

            var conventions  = new ConventionSet();
            var modelBuilder = new ModelBuilder(conventions);

            migration.BuildTargetModel(modelBuilder);
            Assert.Empty(modelBuilder.Model.EntityTypes);
        }