// <summary>Initializes a new instance of the <see cref="T:System.Data.Entity.ModelConfiguration.Configuration.CascadableNavigationPropertyConfiguration" /> class.</summary>
        internal CascadableNavigationPropertyConfiguration(
            NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            DebugCheck.NotNull(navigationPropertyConfiguration);

            _navigationPropertyConfiguration = navigationPropertyConfiguration;
        }
        protected CascadableNavigationPropertyConfiguration(
            NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            Check.NotNull(navigationPropertyConfiguration, "navigationPropertyConfiguration");

            _navigationPropertyConfiguration = navigationPropertyConfiguration;
        }
        internal CascadableNavigationPropertyConfiguration(
            NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            Contract.Requires(navigationPropertyConfiguration != null);

            _navigationPropertyConfiguration = navigationPropertyConfiguration;
        }
        internal ManyToManyNavigationPropertyConfiguration(
            NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            DebugCheck.NotNull(navigationPropertyConfiguration);

            _navigationPropertyConfiguration = navigationPropertyConfiguration;
        }
        private NavigationPropertyConfiguration(NavigationPropertyConfiguration source)
        {
            DebugCheck.NotNull(source);

            _navigationProperty = source._navigationProperty;
            _endKind = source._endKind;
            _inverseNavigationProperty = source._inverseNavigationProperty;
            _inverseEndKind = source._inverseEndKind;

            _constraint = source._constraint == null
                              ? null
                              : source._constraint.Clone();

            _associationMappingConfiguration
                = source._associationMappingConfiguration == null
                      ? null
                      : source._associationMappingConfiguration.Clone();

            DeleteAction = source.DeleteAction;
            IsNavigationPropertyDeclaringTypePrincipal = source.IsNavigationPropertyDeclaringTypePrincipal;

            _modificationFunctionsConfiguration
                = source._modificationFunctionsConfiguration == null
                      ? null
                      : source._modificationFunctionsConfiguration.Clone();
        }
        public void Inverse_navigation_property_should_throw_when_self_inverse()
        {
            var mockPropertyInfo = new MockPropertyInfo();
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(mockPropertyInfo);

            Assert.Equal(Strings.NavigationInverseItself("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => navigationPropertyConfiguration.InverseNavigationProperty = mockPropertyInfo).Message);
        }
        internal ManyToManyNavigationPropertyConfiguration(
            NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            Contract.Requires(navigationPropertyConfiguration != null);

            _navigationPropertyConfiguration = navigationPropertyConfiguration;
        }
        public void Configure_should_configure_inverse()
        {
            var inverseMockPropertyInfo = new MockPropertyInfo();
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo())
                                                      {
                                                          InverseNavigationProperty = inverseMockPropertyInfo
                                                      };
            var associationType = new EdmAssociationType().Initialize();
            var inverseAssociationType = new EdmAssociationType().Initialize();
            var model = new EdmModel().Initialize();
            model.AddAssociationType(inverseAssociationType);
            var inverseNavigationProperty
                = model.AddEntityType("T")
                    .AddNavigationProperty("N", inverseAssociationType);
            inverseNavigationProperty.SetClrPropertyInfo(inverseMockPropertyInfo);

            navigationPropertyConfiguration.Configure(
                new EdmNavigationProperty
                    {
                        Association = associationType
                    }, model, new EntityTypeConfiguration(typeof(object)));

            Assert.Same(associationType, inverseNavigationProperty.Association);
            Assert.Same(associationType.SourceEnd, inverseNavigationProperty.ResultEnd);
            Assert.Equal(0, model.GetAssociationTypes().Count());
        }
        public void Configure_should_configure_inverse()
        {
            var inverseMockPropertyInfo = new MockPropertyInfo();
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo())
                                                      {
                                                          InverseNavigationProperty = inverseMockPropertyInfo
                                                      };
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
            var inverseAssociationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
            inverseAssociationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            inverseAssociationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
            var model = new EdmModel(DataSpace.CSpace);
            model.AddAssociationType(inverseAssociationType);
            var inverseNavigationProperty
                = model.AddEntityType("T")
                       .AddNavigationProperty("N", inverseAssociationType);
            inverseNavigationProperty.SetClrPropertyInfo(inverseMockPropertyInfo);

            navigationPropertyConfiguration.Configure(
                new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
                    {
                        RelationshipType = associationType
                    }, model, new EntityTypeConfiguration(typeof(object)));

            Assert.Same(associationType, inverseNavigationProperty.Association);
            Assert.Same(associationType.SourceEnd, inverseNavigationProperty.ResultEnd);
            Assert.Same(associationType.TargetEnd, inverseNavigationProperty.FromEndMember);
            Assert.Equal(0, model.AssociationTypes.Count());
        }
        public void Has_foreign_key_should_throw_when_invalid_key_expression()
        {
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            Assert.Equal(Strings.InvalidPropertiesExpression("d => d.ToString()"), Assert.Throws<InvalidOperationException>(() => new DependentNavigationPropertyConfiguration<D>(navigationPropertyConfiguration)
                                                                                                                                            .HasForeignKey(d => d.ToString())).Message);
        }
        public void Ctor_should_set_source_end_kind_to_optional()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration);

            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, associationConfiguration.RelationshipMultiplicity);
        }
        public void With_required_should_set_target_end_kind_to_required()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration).WithRequired();

            Assert.Equal(EdmAssociationEndKind.Required, associationConfiguration.InverseEndKind);
        }
        public void With_optional_principal_should_set_inverse_when_specified()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration).WithOptionalPrincipal(t => t.S);

            Assert.Equal("S", associationConfiguration.InverseNavigationProperty.Name);
        }
Esempio n. 14
0
        public void With_many_should_set_inverse_when_specified()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(new MockType(), "N"));

            new ManyNavigationPropertyConfiguration<S, T>(associationConfiguration).WithMany(t => t.Ss);

            Assert.Equal("Ss", associationConfiguration.InverseNavigationProperty.Name);
        }
Esempio n. 15
0
        public void Ctor_should_set_source_end_kind_to_many()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(new MockType(), "N"));

            new ManyNavigationPropertyConfiguration<S, T>(associationConfiguration);

            Assert.Equal(RelationshipMultiplicity.Many, associationConfiguration.RelationshipMultiplicity);
        }
        public void With_optional_dependent_should_set_target_end_kind_to_optional()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration).WithOptionalDependent();

            Assert.Equal(EdmAssociationEndKind.Optional, associationConfiguration.InverseEndKind);
        }
        public void Will_cascade_should_set_correct_delete_action()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new ForeignKeyNavigationPropertyConfiguration(associationConfiguration).WillCascadeOnDelete();

            Assert.Equal(EdmOperationAction.Cascade, associationConfiguration.DeleteAction);
        }
        public void Will_cascade_false_should_set_correct_delete_action()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));

            new ForeignKeyNavigationPropertyConfiguration(associationConfiguration).WillCascadeOnDelete(false);

            Assert.Equal(OperationAction.None, associationConfiguration.DeleteAction);
        }
        public void With_optional_dependent_should_set_inverse_when_specified()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration).WithOptionalDependent(t => t.S);

            Assert.Equal("S", associationConfiguration.InverseNavigationProperty.Name);
        }
        public void With_many_should_set_target_end_kind_to_many()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration).WithMany();

            Assert.Equal(RelationshipMultiplicity.Many, associationConfiguration.InverseEndKind);
        }
        public void With_optional_dependent_should_set_target_end_kind_to_optional()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration).WithOptionalDependent();

            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, associationConfiguration.InverseEndKind);
        }
        public void With_required_should_set_inverse_when_specified()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new ManyNavigationPropertyConfiguration<S, T>(associationConfiguration).WithRequired(t => t.S);

            Assert.Equal("S", associationConfiguration.InverseNavigationProperty.Name);
        }
        public void Ctor_should_set_source_end_kind_to_optional()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new OptionalNavigationPropertyConfiguration<S, T>(associationConfiguration);

            Assert.Equal(EdmAssociationEndKind.Optional, associationConfiguration.EndKind);
        }
        public void With_required_dependent_should_set_target_end_kind_to_required()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new RequiredNavigationPropertyConfiguration<S, T>(associationConfiguration).WithRequiredDependent();

            Assert.Equal(RelationshipMultiplicity.One, associationConfiguration.InverseEndKind);
        }
        public void With_many_should_set_target_end_kind_to_many()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new ManyNavigationPropertyConfiguration<S, T>(associationConfiguration).WithMany();

            Assert.Equal(EdmAssociationEndKind.Many, associationConfiguration.InverseEndKind);
        }
        public void With_optional_should_set_target_end_kind_to_optional()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new RequiredNavigationPropertyConfiguration<S, T>(associationConfiguration).WithOptional();

            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, associationConfiguration.InverseEndKind);
        }
        public void With_required_principal_should_set_inverse_when_specified()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));

            new RequiredNavigationPropertyConfiguration<S, T>(associationConfiguration).WithRequiredPrincipal(t => t.S);

            Assert.Equal("S", associationConfiguration.InverseNavigationProperty.Name);
        }
        public void Ctor_should_set_source_end_kind_to_required()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));

            new RequiredNavigationPropertyConfiguration<S, T>(associationConfiguration);

            Assert.Equal(RelationshipMultiplicity.One, associationConfiguration.RelationshipMultiplicity);
        }
        public void Apply_should_make_end_kind_required()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new RequiredNavigationPropertyAttributeConvention()
                .Apply(new MockPropertyInfo(), associationConfiguration, new RequiredAttribute());

            Assert.Equal(RelationshipMultiplicity.One, associationConfiguration.RelationshipMultiplicity);
        }
        public void Apply_should_make_end_kind_required()
        {
            var associationConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());

            new RequiredNavigationPropertyAttributeConvention.RequiredNavigationPropertyAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), associationConfiguration, new RequiredAttribute());

            Assert.Equal(EdmAssociationEndKind.Required, associationConfiguration.EndKind);
        }
Esempio n. 31
0
        public void MapToStoredProcedures_when_configuration_should_assign_configuration_to_nav_prop_configuration()
        {
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo());
            var manyToManyNavigationPropertyConfiguration
                = new ManyToManyNavigationPropertyConfiguration <string, string>(navigationPropertyConfiguration);

            var called = false;

            manyToManyNavigationPropertyConfiguration.MapToStoredProcedures(m => { called = true; });

            Assert.True(called);
            Assert.NotNull(navigationPropertyConfiguration.ModificationFunctionsConfiguration);
        }
        public void Configure_should_configure_function_mapping()
        {
            var functionsConfiguration = new ModificationStoredProceduresConfiguration();
            var functionConfiguration  = new ModificationStoredProcedureConfiguration();

            functionConfiguration.HasName("Func");
            functionsConfiguration.Insert(functionConfiguration);

            var mockPropertyInfo = new MockPropertyInfo(typeof(AType1), "N");

            var navigationPropertyConfiguration
                = new NavigationPropertyConfiguration(mockPropertyInfo)
                {
                ModificationStoredProceduresConfiguration = functionsConfiguration
                };

            var databaseMapping
                = new DbDatabaseMapping()
                  .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace));

            var associationType
                = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)
                {
                SourceEnd =
                    new AssociationEndMember(
                        "S",
                        new EntityType(
                            "E1", "N", DataSpace.CSpace)),
                TargetEnd =
                    new AssociationEndMember(
                        "T",
                        new EntityType(
                            "E2", "N", DataSpace.CSpace))
                };

            associationType.SourceEnd.SetClrPropertyInfo(mockPropertyInfo);

            var associationSetMapping
                = databaseMapping.AddAssociationSetMapping(new AssociationSet("AS", associationType), new EntitySet());

            var dependentTable = databaseMapping.Database.AddTable("T");

            associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable);
            associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration);

            associationSetMapping.SourceEndMapping.AssociationEnd = associationType.SourceEnd;

            navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);

            Assert.Equal("Func", associationSetMapping.ModificationFunctionMapping.InsertFunctionMapping.Function.StoreFunctionNameAttribute);
        }
Esempio n. 33
0
        public void HasDeleteAction_sets_the_DeleteAction()
        {
            var configuration =
                new NavigationPropertyConfiguration(
                    typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty"));
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());

            lightweightConfiguration.HasDeleteAction(OperationAction.Cascade);
            Assert.Equal(OperationAction.Cascade, configuration.DeleteAction);

            configuration.DeleteAction = OperationAction.None;
            lightweightConfiguration.HasDeleteAction(OperationAction.Cascade);
            Assert.Equal(OperationAction.None, configuration.DeleteAction);
        }
        public void Configure_should_ensure_consistency_of_principality_when_already_configured()
        {
            var associationType  = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
            var sourceEntityType = new EntityType("SE", "N", DataSpace.CSpace);

            associationType.SourceEnd = new AssociationEndMember("S", sourceEntityType);
            var targetEntityType = new EntityType("TE", "N", DataSpace.CSpace);

            associationType.TargetEnd = new AssociationEndMember("T", targetEntityType);

            var navPropertyInfoA = new MockPropertyInfo(typeof(AType1), "N1");
            var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(navPropertyInfoA);

            associationType.SetConfiguration(navigationPropertyConfigurationA);
            var navPropertyA = new NavigationProperty("N1", TypeUsage.Create(targetEntityType));

            navPropertyA.SetClrPropertyInfo(navPropertyInfoA);
            navPropertyA.RelationshipType = associationType;
            navPropertyA.ToEndMember      = associationType.TargetEnd;
            navPropertyA.FromEndMember    = associationType.SourceEnd;
            sourceEntityType.AddNavigationProperty(navPropertyA);

            var navPropertyInfoB = new MockPropertyInfo(typeof(AType1), "N2");
            var navigationPropertyConfigurationB
                = new NavigationPropertyConfiguration(navPropertyInfoB)
                {
                IsNavigationPropertyDeclaringTypePrincipal = false
                };
            var navPropertyB = new NavigationProperty("N2", TypeUsage.Create(sourceEntityType));

            navPropertyB.SetClrPropertyInfo(navPropertyInfoB);
            navPropertyB.RelationshipType = associationType;
            navPropertyB.ToEndMember      = associationType.SourceEnd;
            navPropertyB.FromEndMember    = associationType.TargetEnd;
            targetEntityType.AddNavigationProperty(navPropertyB);

            var model = new EdmModel(DataSpace.CSpace);

            model.AddItem(sourceEntityType);
            model.AddItem(targetEntityType);

            navigationPropertyConfigurationB.Configure(
                new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
            {
                RelationshipType = associationType
            },
                model, new EntityTypeConfiguration(typeof(object)));

            Assert.Equal(true, navigationPropertyConfigurationA.IsNavigationPropertyDeclaringTypePrincipal);
        }
Esempio n. 35
0
        public void IsDeclaringTypePrincipal_sets_IsNavigationPropertyDeclaringTypePrincipal()
        {
            var configuration =
                new NavigationPropertyConfiguration(
                    typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty"));
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());

            lightweightConfiguration.IsDeclaringTypePrincipal(false);
            Assert.Equal(false, configuration.IsNavigationPropertyDeclaringTypePrincipal);

            configuration.IsNavigationPropertyDeclaringTypePrincipal = true;
            lightweightConfiguration.IsDeclaringTypePrincipal(false);
            Assert.Equal(true, configuration.IsNavigationPropertyDeclaringTypePrincipal);
        }
Esempio n. 36
0
        public void HasRelationshipMultiplicity_gets_and_sets_the_RelationshipMultiplicity()
        {
            var configuration =
                new NavigationPropertyConfiguration(
                    typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty"));
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());

            lightweightConfiguration.HasRelationshipMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, configuration.RelationshipMultiplicity);

            configuration.RelationshipMultiplicity = RelationshipMultiplicity.Many;
            lightweightConfiguration.HasRelationshipMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            Assert.Equal(RelationshipMultiplicity.Many, configuration.RelationshipMultiplicity);
        }
        public void HasInverseEndMultiplicity_sets_the_InverseEndKind()
        {
            var configuration =
                new NavigationPropertyConfiguration(
                    typeof(LightweighEntity).GetProperty("ValidNavigationProperty"));
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());

            lightweightConfiguration.HasInverseEndMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, configuration.InverseEndKind);

            configuration.InverseEndKind = RelationshipMultiplicity.Many;
            lightweightConfiguration.HasInverseEndMultiplicity(RelationshipMultiplicity.ZeroOrOne);
            Assert.Equal(RelationshipMultiplicity.Many, configuration.InverseEndKind);
        }
Esempio n. 38
0
        public void HasInverseNavigationProperty_throws_on_nonmatching_nagivation_property()
        {
            var navigationProperty       = typeof(LightweighEntity).GetDeclaredProperty("UnrelatedNavigationProperty");
            var configuration            = new NavigationPropertyConfiguration(navigationProperty);
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());

            var inverseNavigationProperty = typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty");

            Assert.Equal(
                Strings.LightweightEntityConfiguration_MismatchedInverseNavigationProperty(
                    typeof(ConventionNavigationPropertyConfigurationTests), navigationProperty.Name,
                    typeof(LightweighEntity), inverseNavigationProperty.Name),
                Assert.Throws <InvalidOperationException>(
                    () => lightweightConfiguration.HasInverseNavigationProperty(p => inverseNavigationProperty)).Message);
        }
Esempio n. 39
0
        public void HasRelationshipMultiplicity_throws_on_incompatible_multiplicity()
        {
            var navigationProperty       = typeof(LightweighEntity).GetDeclaredProperty("PrivateNavigationProperty");
            var configuration            = new NavigationPropertyConfiguration(navigationProperty);
            var modelConfiguration       = new ModelConfiguration();
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, modelConfiguration);

            Assert.Equal(
                Strings.LightweightNavigationPropertyConfiguration_IncompatibleMultiplicity(
                    "0..1",
                    typeof(LightweighEntity).Name + "." + "PrivateNavigationProperty",
                    "System.Collections.Generic.ICollection`1[" +
                    typeof(LightweighEntity).FullName + "]"),
                Assert.Throws <InvalidOperationException>(
                    () => lightweightConfiguration.HasRelationshipMultiplicity(RelationshipMultiplicity.ZeroOrOne)).Message);
        }
        public void Configure_should_set_configuration_annotations()
        {
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));
            var navigationProperty = new NavigationProperty("N", TypeUsage.Create(new EntityType("E", "N", DataSpace.CSpace)))
            {
                RelationshipType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)
            };

            navigationProperty.Association.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            navigationProperty.Association.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));

            navigationPropertyConfiguration.Configure(
                navigationProperty, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)));

            Assert.NotNull(navigationProperty.GetConfiguration());
            Assert.NotNull(navigationProperty.Association.GetConfiguration());
        }
        public void Configure_should_validate_consistency_of_function_configuration_when_already_configured()
        {
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));

            var functionConfiguration1 = new ModificationStoredProcedureConfiguration();

            functionConfiguration1.HasName("Foo");

            var functionConfiguration2 = new ModificationStoredProcedureConfiguration();

            functionConfiguration2.HasName("Bar");

            var functionsConfiguration1 = new ModificationStoredProceduresConfiguration();

            functionsConfiguration1.Insert(functionConfiguration1);

            var functionsConfiguration2 = new ModificationStoredProceduresConfiguration();

            functionsConfiguration2.Insert(functionConfiguration2);

            var navigationPropertyConfigurationA
                = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1"))
                {
                ModificationStoredProceduresConfiguration = functionsConfiguration1
                };

            associationType.SetConfiguration(navigationPropertyConfigurationA);

            var navigationPropertyConfigurationB
                = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2"))
                {
                ModificationStoredProceduresConfiguration = functionsConfiguration2
                };

            Assert.Equal(
                Strings.ConflictingFunctionsMapping("N2", typeof(object)),
                Assert.Throws <InvalidOperationException>(
                    () => navigationPropertyConfigurationB.Configure(
                        new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
            {
                RelationshipType = associationType
            }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)))).Message);
        }
        private NavigationPropertyConfiguration(NavigationPropertyConfiguration source)
        {
            DebugCheck.NotNull(source);

            _navigationProperty        = source._navigationProperty;
            _endKind                   = source._endKind;
            _inverseNavigationProperty = source._inverseNavigationProperty;
            _inverseEndKind            = source._inverseEndKind;

            _constraint = source._constraint == null ? null : source._constraint.Clone();

            _associationMappingConfiguration = source._associationMappingConfiguration == null
                                                   ? null
                                                   : source._associationMappingConfiguration.Clone();

            DeleteAction = source.DeleteAction;
            IsNavigationPropertyDeclaringTypePrincipal = source.IsNavigationPropertyDeclaringTypePrincipal;
        }
Esempio n. 43
0
        public void Has_foreign_key_with_multiple_properties_should_create_constraint_with_dependent_keys()
        {
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"));

            new DependentNavigationPropertyConfiguration <D>(navigationPropertyConfiguration)
            .HasForeignKey(
                d => new
            {
                d.Fk1,
                d.Fk2
            });

            var foreignKeyConstraint = (ForeignKeyConstraintConfiguration)navigationPropertyConfiguration.Constraint;

            Assert.Equal(2, foreignKeyConstraint.ToProperties.Count());
            Assert.Equal("Fk1", foreignKeyConstraint.ToProperties.First().Name);
            Assert.Equal("Fk2", foreignKeyConstraint.ToProperties.ElementAt(1).Name);
        }
Esempio n. 44
0
        public void HasConstraint_is_noop_when_set_on_inverse()
        {
            var modelConfiguration        = new ModelConfiguration();
            var inverseNavigationProperty = typeof(LightweighEntity).GetDeclaredProperty("PrivateNavigationProperty");

            modelConfiguration.Entity(typeof(LightweighEntity))
            .Navigation(inverseNavigationProperty)
            .Constraint = IndependentConstraintConfiguration.Instance;
            var configuration =
                new NavigationPropertyConfiguration(
                    typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty"));

            configuration.InverseNavigationProperty = inverseNavigationProperty;
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, modelConfiguration);

            lightweightConfiguration.HasConstraint <ForeignKeyConstraintConfiguration>();
            Assert.Null(configuration.Constraint);
        }
Esempio n. 45
0
        public void HasInverseNavigationProperty_sets_the_InverseNavigationProperty()
        {
            var navigationProperty       = typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty");
            var configuration            = new NavigationPropertyConfiguration(navigationProperty);
            var modelConfiguration       = new ModelConfiguration();
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, modelConfiguration);

            var inverseNavigationProperty1 =
                typeof(LightweighEntity).GetDeclaredProperty("ValidInverseNavigationProperty");

            lightweightConfiguration.HasInverseNavigationProperty(p => inverseNavigationProperty1);
            Assert.Same(inverseNavigationProperty1, configuration.InverseNavigationProperty);

            var inverseNavigationProperty2 = typeof(LightweighEntity).GetDeclaredProperty("PrivateNavigationProperty");

            configuration.InverseNavigationProperty = inverseNavigationProperty2;
            lightweightConfiguration.HasInverseNavigationProperty(p => inverseNavigationProperty1);
            Assert.Same(inverseNavigationProperty2, configuration.InverseNavigationProperty);
        }
Esempio n. 46
0
        public void Configure_should_not_validate_consistency_of_dependent_end_when_both_false()
        {
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
            var navigationPropertyConfigurationA
                = new NavigationPropertyConfiguration(new MockPropertyInfo(new MockType(), "N"));

            associationType.SetConfiguration(navigationPropertyConfigurationA);
            var navigationPropertyConfigurationB
                = new NavigationPropertyConfiguration(new MockPropertyInfo(new MockType(), "N"));

            navigationPropertyConfigurationB.Configure(
                new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
            {
                RelationshipType = associationType
            },
                new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)));
        }
Esempio n. 47
0
        public void HasInverseNavigationProperty_throws_on_incompatible_multiplicity()
        {
            var navigationProperty       = typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty");
            var configuration            = new NavigationPropertyConfiguration(navigationProperty);
            var modelConfiguration       = new ModelConfiguration();
            var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, modelConfiguration);

            var inverseNavigationProperty =
                typeof(LightweighEntity).GetDeclaredProperty("ValidInverseNavigationProperty");

            lightweightConfiguration.HasInverseEndMultiplicity(RelationshipMultiplicity.Many);

            Assert.Equal(
                Strings.LightweightNavigationPropertyConfiguration_IncompatibleMultiplicity(
                    "*",
                    typeof(LightweighEntity).Name + "." + "ValidInverseNavigationProperty",
                    typeof(LightweighEntity).FullName),
                Assert.Throws <InvalidOperationException>(
                    () => lightweightConfiguration.HasInverseNavigationProperty(p => inverseNavigationProperty)).Message);
        }
Esempio n. 48
0
        internal void Configure(
            System.Data.Entity.Core.Metadata.Edm.NavigationProperty navigationProperty,
            EdmModel model,
            EntityTypeConfiguration entityTypeConfiguration)
        {
            navigationProperty.SetConfiguration((object)this);
            AssociationType association = navigationProperty.Association;
            NavigationPropertyConfiguration configuration = association.GetConfiguration() as NavigationPropertyConfiguration;

            if (configuration == null)
            {
                association.SetConfiguration((object)this);
            }
            else
            {
                this.EnsureConsistency(configuration);
            }
            this.ConfigureInverse(association, model);
            this.ConfigureEndKinds(association, configuration);
            this.ConfigureDependentBehavior(association, model, entityTypeConfiguration);
        }
        public void Configure_should_configure_ends()
        {
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N"))
            {
                RelationshipMultiplicity = RelationshipMultiplicity.ZeroOrOne,
                InverseEndKind           = RelationshipMultiplicity.Many
            };
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));

            navigationPropertyConfiguration.Configure(
                new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
            {
                RelationshipType = associationType
            },
                new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)));

            Assert.Equal(RelationshipMultiplicity.Many, associationType.SourceEnd.RelationshipMultiplicity);
            Assert.Equal(RelationshipMultiplicity.ZeroOrOne, associationType.TargetEnd.RelationshipMultiplicity);
        }
Esempio n. 50
0
        private void ConfigureEndKinds(
            AssociationType associationType,
            NavigationPropertyConfiguration configuration)
        {
            AssociationEndMember associationEndMember1 = associationType.SourceEnd;
            AssociationEndMember associationEndMember2 = associationType.TargetEnd;

            if (configuration != null && configuration.InverseNavigationProperty != (PropertyInfo)null)
            {
                associationEndMember1 = associationType.TargetEnd;
                associationEndMember2 = associationType.SourceEnd;
            }
            if (this._inverseEndKind.HasValue)
            {
                associationEndMember1.RelationshipMultiplicity = this._inverseEndKind.Value;
            }
            if (!this._endKind.HasValue)
            {
                return;
            }
            associationEndMember2.RelationshipMultiplicity = this._endKind.Value;
        }
        public void Configure_should_ensure_consistency_of_constraint_when_already_configured()
        {
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("SE", "N", DataSpace.CSpace));

            var targetEntityType = new EntityType("TE", "N", DataSpace.CSpace);
            var propertyInfo     = new MockPropertyInfo(typeof(int), "P2").Object;
            var property         = new EdmProperty("P2", TypeUsage.Create(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)));

            targetEntityType.AddMember(property);
            property.SetClrPropertyInfo(propertyInfo);

            associationType.TargetEnd = new AssociationEndMember("T", targetEntityType);
            var navigationPropertyConfigurationA
                = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1"));

            associationType.SetConfiguration(navigationPropertyConfigurationA);
            var constraint = new ForeignKeyConstraintConfiguration(
                new[]
            {
                propertyInfo
            });
            var navigationPropertyConfigurationB
                = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2"))
                {
                Constraint = constraint
                };

            navigationPropertyConfigurationB.Configure(
                new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
            {
                RelationshipType = associationType
            },
                new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)));

            Assert.Equal(constraint, navigationPropertyConfigurationA.Constraint);
        }
        public void Configure_should_validate_consistency_of_constraint_when_already_configured()
        {
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
            var navigationPropertyConfigurationA
                = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1"))
                {
                Constraint = new ForeignKeyConstraintConfiguration(
                    new[]
                {
                    new MockPropertyInfo(typeof(int), "P1").Object
                })
                };

            associationType.SetConfiguration(navigationPropertyConfigurationA);
            var navigationPropertyConfigurationB
                = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2"))
                {
                Constraint = new ForeignKeyConstraintConfiguration(
                    new[]
                {
                    new MockPropertyInfo(typeof(int), "P2").Object
                })
                };

            Assert.Equal(
                Strings.ConflictingConstraint("N2", typeof(object)),
                Assert.Throws <InvalidOperationException>(
                    () => navigationPropertyConfigurationB.Configure(
                        new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
            {
                RelationshipType = associationType
            },
                        new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)))).Message);
        }
Esempio n. 53
0
 internal ConventionNavigationPropertyConfiguration(
     NavigationPropertyConfiguration configuration, ModelConfiguration modelConfiguration)
 {
     _configuration      = configuration;
     _modelConfiguration = modelConfiguration;
 }
        private void ValidateConsistency(NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            DebugCheck.NotNull(navigationPropertyConfiguration);

            if ((navigationPropertyConfiguration.InverseEndKind != null) &&
                (RelationshipMultiplicity != null) &&
                (navigationPropertyConfiguration.InverseEndKind != RelationshipMultiplicity))
            {
                throw Error.ConflictingMultiplicities(
                          NavigationProperty.Name, NavigationProperty.ReflectedType);
            }

            if ((navigationPropertyConfiguration.RelationshipMultiplicity != null) &&
                (InverseEndKind != null) &&
                (navigationPropertyConfiguration.RelationshipMultiplicity != InverseEndKind))
            {
                if (InverseNavigationProperty == null)
                {
                    // InverseNavigationProperty may be null if the association is bi-directional and is configured
                    // from both sides but on one side the navigation property is not specified in the configuration.
                    // See Dev11 330745.
                    // In this case we use the navigation property that we do know about in the exception message.
                    throw Error.ConflictingMultiplicities(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
                throw Error.ConflictingMultiplicities(
                          InverseNavigationProperty.Name, InverseNavigationProperty.ReflectedType);
            }

            if ((navigationPropertyConfiguration.DeleteAction != null) &&
                (DeleteAction != null) &&
                (navigationPropertyConfiguration.DeleteAction != DeleteAction))
            {
                throw Error.ConflictingCascadeDeleteOperation(
                          NavigationProperty.Name, NavigationProperty.ReflectedType);
            }

            if ((navigationPropertyConfiguration.Constraint != null) &&
                (Constraint != null) &&
                !Equals(navigationPropertyConfiguration.Constraint, Constraint))
            {
                throw Error.ConflictingConstraint(
                          NavigationProperty.Name, NavigationProperty.ReflectedType);
            }

            if ((navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal != null) &&
                (IsNavigationPropertyDeclaringTypePrincipal != null)
                &&
                navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal
                == IsNavigationPropertyDeclaringTypePrincipal)
            {
                throw Error.ConflictingConstraint(
                          NavigationProperty.Name, NavigationProperty.ReflectedType);
            }

            if ((navigationPropertyConfiguration.AssociationMappingConfiguration != null) &&
                (AssociationMappingConfiguration != null)
                &&
                !Equals(
                    navigationPropertyConfiguration.AssociationMappingConfiguration, AssociationMappingConfiguration))
            {
                throw Error.ConflictingMapping(
                          NavigationProperty.Name, NavigationProperty.ReflectedType);
            }
        }
Esempio n. 55
0
 private void EnsureConsistency(
     NavigationPropertyConfiguration navigationPropertyConfiguration)
 {
     if (this.RelationshipMultiplicity.HasValue)
     {
         if (!navigationPropertyConfiguration.InverseEndKind.HasValue)
         {
             navigationPropertyConfiguration.InverseEndKind = this.RelationshipMultiplicity;
         }
         else
         {
             System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity?inverseEndKind           = navigationPropertyConfiguration.InverseEndKind;
             System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity?relationshipMultiplicity = this.RelationshipMultiplicity;
             if ((inverseEndKind.GetValueOrDefault() != relationshipMultiplicity.GetValueOrDefault() ? 1 : (inverseEndKind.HasValue != relationshipMultiplicity.HasValue ? 1 : 0)) != 0)
             {
                 throw Error.ConflictingMultiplicities((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
             }
         }
     }
     if (this.InverseEndKind.HasValue)
     {
         if (!navigationPropertyConfiguration.RelationshipMultiplicity.HasValue)
         {
             navigationPropertyConfiguration.RelationshipMultiplicity = this.InverseEndKind;
         }
         else
         {
             System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity?relationshipMultiplicity = navigationPropertyConfiguration.RelationshipMultiplicity;
             System.Data.Entity.Core.Metadata.Edm.RelationshipMultiplicity?inverseEndKind           = this.InverseEndKind;
             if ((relationshipMultiplicity.GetValueOrDefault() != inverseEndKind.GetValueOrDefault() ? 1 : (relationshipMultiplicity.HasValue != inverseEndKind.HasValue ? 1 : 0)) != 0)
             {
                 if (this.InverseNavigationProperty == (PropertyInfo)null)
                 {
                     throw Error.ConflictingMultiplicities((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
                 }
                 throw Error.ConflictingMultiplicities((object)this.InverseNavigationProperty.Name, (object)this.InverseNavigationProperty.ReflectedType);
             }
         }
     }
     if (this.DeleteAction.HasValue)
     {
         if (!navigationPropertyConfiguration.DeleteAction.HasValue)
         {
             navigationPropertyConfiguration.DeleteAction = this.DeleteAction;
         }
         else
         {
             OperationAction?deleteAction1 = navigationPropertyConfiguration.DeleteAction;
             OperationAction?deleteAction2 = this.DeleteAction;
             if ((deleteAction1.GetValueOrDefault() != deleteAction2.GetValueOrDefault() ? 1 : (deleteAction1.HasValue != deleteAction2.HasValue ? 1 : 0)) != 0)
             {
                 throw Error.ConflictingCascadeDeleteOperation((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
             }
         }
     }
     if (this.Constraint != null)
     {
         if (navigationPropertyConfiguration.Constraint == null)
         {
             navigationPropertyConfiguration.Constraint = this.Constraint;
         }
         else if (!object.Equals((object)navigationPropertyConfiguration.Constraint, (object)this.Constraint))
         {
             throw Error.ConflictingConstraint((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
         }
     }
     if (this.IsNavigationPropertyDeclaringTypePrincipal.HasValue)
     {
         if (!navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal.HasValue)
         {
             NavigationPropertyConfiguration propertyConfiguration = navigationPropertyConfiguration;
             bool?declaringTypePrincipal = this.IsNavigationPropertyDeclaringTypePrincipal;
             bool?nullable = declaringTypePrincipal.HasValue ? new bool?(!declaringTypePrincipal.GetValueOrDefault()) : new bool?();
             propertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal = nullable;
         }
         else
         {
             bool?declaringTypePrincipal1 = navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal;
             bool?declaringTypePrincipal2 = this.IsNavigationPropertyDeclaringTypePrincipal;
             if ((declaringTypePrincipal1.GetValueOrDefault() != declaringTypePrincipal2.GetValueOrDefault() ? 0 : (declaringTypePrincipal1.HasValue == declaringTypePrincipal2.HasValue ? 1 : 0)) != 0)
             {
                 throw Error.ConflictingConstraint((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
             }
         }
     }
     if (this.AssociationMappingConfiguration != null)
     {
         if (navigationPropertyConfiguration.AssociationMappingConfiguration == null)
         {
             navigationPropertyConfiguration.AssociationMappingConfiguration = this.AssociationMappingConfiguration;
         }
         else if (!object.Equals((object)navigationPropertyConfiguration.AssociationMappingConfiguration, (object)this.AssociationMappingConfiguration))
         {
             throw Error.ConflictingMapping((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
         }
     }
     if (this.ModificationStoredProceduresConfiguration == null)
     {
         return;
     }
     if (navigationPropertyConfiguration.ModificationStoredProceduresConfiguration == null)
     {
         navigationPropertyConfiguration.ModificationStoredProceduresConfiguration = this.ModificationStoredProceduresConfiguration;
     }
     else if (!navigationPropertyConfiguration.ModificationStoredProceduresConfiguration.IsCompatibleWith(this.ModificationStoredProceduresConfiguration))
     {
         throw Error.ConflictingFunctionsMapping((object)this.NavigationProperty.Name, (object)this.NavigationProperty.ReflectedType);
     }
 }
Esempio n. 56
0
        private void EnsureConsistency(NavigationPropertyConfiguration navigationPropertyConfiguration)
        {
            DebugCheck.NotNull(navigationPropertyConfiguration);

            if (RelationshipMultiplicity != null)
            {
                if (navigationPropertyConfiguration.InverseEndKind == null)
                {
                    navigationPropertyConfiguration.InverseEndKind = RelationshipMultiplicity;
                }
                else if (navigationPropertyConfiguration.InverseEndKind != RelationshipMultiplicity)
                {
                    throw Error.ConflictingMultiplicities(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
            }

            if (InverseEndKind != null)
            {
                if (navigationPropertyConfiguration.RelationshipMultiplicity == null)
                {
                    navigationPropertyConfiguration.RelationshipMultiplicity = InverseEndKind;
                }
                else if (navigationPropertyConfiguration.RelationshipMultiplicity != InverseEndKind)
                {
                    if (InverseNavigationProperty == null)
                    {
                        // InverseNavigationProperty may be null if the association is bi-directional and is configured
                        // from both sides but on one side the navigation property is not specified in the configuration.
                        // See Dev11 330745.
                        // In this case we use the navigation property that we do know about in the exception message.
                        throw Error.ConflictingMultiplicities(
                                  NavigationProperty.Name, NavigationProperty.ReflectedType);
                    }
                    throw Error.ConflictingMultiplicities(
                              InverseNavigationProperty.Name, InverseNavigationProperty.ReflectedType);
                }
            }

            if (DeleteAction != null)
            {
                if (navigationPropertyConfiguration.DeleteAction == null)
                {
                    navigationPropertyConfiguration.DeleteAction = DeleteAction;
                }
                else if (navigationPropertyConfiguration.DeleteAction != DeleteAction)
                {
                    throw Error.ConflictingCascadeDeleteOperation(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
            }

            if (Constraint != null)
            {
                if (navigationPropertyConfiguration.Constraint == null)
                {
                    navigationPropertyConfiguration.Constraint = Constraint;
                }
                else if (!Equals(navigationPropertyConfiguration.Constraint, Constraint))
                {
                    throw Error.ConflictingConstraint(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
            }

            if (IsNavigationPropertyDeclaringTypePrincipal != null)
            {
                if (navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal == null)
                {
                    navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal =
                        !IsNavigationPropertyDeclaringTypePrincipal;
                }
                else if (navigationPropertyConfiguration.IsNavigationPropertyDeclaringTypePrincipal
                         == IsNavigationPropertyDeclaringTypePrincipal)
                {
                    throw Error.ConflictingConstraint(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
            }

            if (AssociationMappingConfiguration != null)
            {
                if (navigationPropertyConfiguration.AssociationMappingConfiguration == null)
                {
                    navigationPropertyConfiguration.AssociationMappingConfiguration = AssociationMappingConfiguration;
                }
                else if (!Equals(
                             navigationPropertyConfiguration.AssociationMappingConfiguration, AssociationMappingConfiguration))
                {
                    throw Error.ConflictingMapping(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
            }

            if (ModificationStoredProceduresConfiguration != null)
            {
                if (navigationPropertyConfiguration.ModificationStoredProceduresConfiguration == null)
                {
                    navigationPropertyConfiguration.ModificationStoredProceduresConfiguration = ModificationStoredProceduresConfiguration;
                }
                else if (
                    !navigationPropertyConfiguration.ModificationStoredProceduresConfiguration.IsCompatibleWith(
                        ModificationStoredProceduresConfiguration))
                {
                    throw Error.ConflictingFunctionsMapping(
                              NavigationProperty.Name, NavigationProperty.ReflectedType);
                }
            }
        }