public void AddAssociationSetMapping_should_add_mapping()
        {
            var databaseMapping = new DbDatabaseMapping()
                .Initialize(new EdmModel().Initialize(), new DbDatabaseMetadata());
            var associationSet = new EdmAssociationSet();

            var associationSetMapping = databaseMapping.AddAssociationSetMapping(associationSet);

            Assert.NotNull(associationSetMapping);
            Assert.Equal(1, databaseMapping.EntityContainerMappings.Single().AssociationSetMappings.Count());
            Assert.Same(associationSet, associationSetMapping.AssociationSet);
        }
        internal static DbAssociationSetMapping AddAssociationSetMapping(
            this DbDatabaseMapping databaseMapping, EdmAssociationSet associationSet)
        {
            Contract.Requires(databaseMapping != null);
            Contract.Requires(associationSet != null);

            var associationSetMapping
                = new DbAssociationSetMapping
                    {
                        AssociationSet = associationSet
                    }.Initialize();

            databaseMapping
                .EntityContainerMappings
                .Single()
                .AssociationSetMappings
                .Add(associationSetMapping);

            return associationSetMapping;
        }
        public static EdmAssociationSet AddAssociationSet(
            this EdmModel model, string name, EdmAssociationType associationType)
        {
            //Contract.Requires(model != null);
            //Contract.Requires(!string.IsNullOrWhiteSpace(name));
            //Contract.Requires(associationType != null);
            Contract.Assert(model.Containers.Count == 1);

            var associationSet = new EdmAssociationSet
                {
                    Name = name,
                    ElementType = associationType,
                    SourceSet = model.GetEntitySet(associationType.SourceEnd.EntityType),
                    TargetSet = model.GetEntitySet(associationType.TargetEnd.EntityType)
                };

            model.Containers.Single().AssociationSets.Add(associationSet);

            return associationSet;
        }