Example #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 ApplyDatabase_should_run_database_conventions()
        {
            var database = new DbDatabaseMetadata().Initialize();
            var mockConvention = new Mock<IDbConvention>();
            var conventionsConfiguration = new ConventionsConfiguration(new[] { mockConvention.Object });

            conventionsConfiguration.ApplyDatabase(database);

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

            conventionsConfiguration.ApplyDatabase(database);

            mockConvention.Verify(c => c.Apply(database), Times.AtMostOnce());
        }
        public void ApplyDatabase_should_run_targeted_model_conventions()
        {
            var database                 = new EdmModel().Initialize();
            var table                    = database.AddTable("T");
            var mockConvention           = new Mock <IDbConvention <EntityType> >();
            var conventionsConfiguration = new ConventionsConfiguration(
                new IConvention[]
            {
                mockConvention.Object
            });

            conventionsConfiguration.ApplyDatabase(database);

            mockConvention.Verify(c => c.Apply(table, database), Times.AtMostOnce());
        }
        public void ApplyDatabase_should_run_targeted_model_conventions()
        {
            var database = new DbDatabaseMetadata().Initialize();
            var table = database.AddTable("T");
            var mockConvention = new Mock<IDbConvention<DbTableMetadata>>();
            var conventionsConfiguration = new ConventionsConfiguration(
                new IConvention[]
                    {
                        mockConvention.Object
                    });

            conventionsConfiguration.ApplyDatabase(database);

            mockConvention.Verify(c => c.Apply(table, database), Times.AtMostOnce());
        }
        public void ApplyDatabase_should_run_database_conventions()
        {
            var database = new EdmModel(DataSpace.CSpace);
            var mockConvention = new Mock<IDbConvention>();
            var conventionsConfiguration = new ConventionsConfiguration(new[] { mockConvention.Object });

            conventionsConfiguration.ApplyDatabase(database);

            mockConvention.Verify(c => c.Apply(database), Times.AtMostOnce());
        }
        public void ApplyDatabase_should_run_targeted_model_conventions()
        {
            var database = new EdmModel(DataSpace.SSpace);
            var table = database.AddTable("T");
            var mockConvention = new Mock<IDbConvention<EntityType>>();
            var conventionsConfiguration = new ConventionsConfiguration(
                new IConvention[]
                    {
                        mockConvention.Object
                    });
            
            conventionsConfiguration.ApplyDatabase(database);

            mockConvention.Verify(c => c.Apply(table, database), Times.AtMostOnce());
        }