Пример #1
0
        private DbModel Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
        {
            DebugCheck.NotNull(providerManifest);
            DebugCheck.NotNull(providerInfo);

            var model = new EdmModel().Initialize(_modelBuilderVersion.GetEdmVersion());

            model.SetProviderInfo(providerInfo);

            _conventionsConfiguration.ApplyModelConfiguration(_modelConfiguration);

            _modelConfiguration.NormalizeConfigurations();

            MapTypes(model);

            _modelConfiguration.Configure(model);
            _conventionsConfiguration.ApplyModel(model);

            model.ValidateCsdl();

            var databaseMapping = model.GenerateDatabaseMapping(providerManifest);

            //Running the PluralizingTableNameConvention first so that the new table name is available for configuration
            _conventionsConfiguration.ApplyPluralizingTableNameConvention(databaseMapping.Database);
            _modelConfiguration.Configure(databaseMapping, providerManifest);
            _conventionsConfiguration.ApplyDatabase(databaseMapping.Database);
            _conventionsConfiguration.ApplyMapping(databaseMapping);

            databaseMapping.Database.SetProviderInfo(providerInfo);

            return(new DbModel(databaseMapping, Clone()));
        }
        public void ApplyModel_should_run_model_conventions()
        {
            var model = new EdmModel().Initialize();
            var mockConvention = new Mock<IEdmConvention>();
            var conventionsConfiguration = new ConventionsConfiguration(new[] { mockConvention.Object });

            conventionsConfiguration.ApplyModel(model);

            mockConvention.Verify(c => c.Apply(model), Times.AtMostOnce());
        }
        public void ApplyModel_should_run_model_conventions()
        {
            var model                    = new EdmModel().Initialize();
            var mockConvention           = new Mock <IEdmConvention>();
            var conventionsConfiguration = new ConventionsConfiguration(new[] { mockConvention.Object });

            conventionsConfiguration.ApplyModel(model);

            mockConvention.Verify(c => c.Apply(model), Times.AtMostOnce());
        }
        public void ApplyModel_should_run_targeted_model_conventions()
        {
            var model                    = new EdmModel().Initialize();
            var entityType               = model.AddEntityType("E");
            var mockConvention           = new Mock <IEdmConvention <EntityType> >();
            var conventionsConfiguration = new ConventionsConfiguration(
                new IConvention[]
            {
                mockConvention.Object
            });

            conventionsConfiguration.ApplyModel(model);

            mockConvention.Verify(c => c.Apply(entityType, model), Times.AtMostOnce());
        }
        public void ApplyModel_should_run_targeted_model_conventions()
        {
            var model = new EdmModel().Initialize();
            var entityType = model.AddEntityType("E");
            var mockConvention = new Mock<IEdmConvention<EdmEntityType>>();
            var conventionsConfiguration = new ConventionsConfiguration(
                new IConvention[]
                    {
                        mockConvention.Object
                    });

            conventionsConfiguration.ApplyModel(model);

            mockConvention.Verify(c => c.Apply(entityType, model), Times.AtMostOnce());
        }