public static void InitializeModelFirstDatabases(bool runInitializers = true)
        {
            const string prefix = "System.Data.Entity.TestModels.TemplateModels.Schemas.";

            ResourceUtilities.CopyEmbeddedResourcesToCurrentDir(
                typeof(TemplateTests).Assembly(),
                prefix,
                /*overwrite*/ true,
                "AdvancedPatterns.edmx",
                "MonsterModel.csdl",
                "MonsterModel.msl",
                "MonsterModel.ssdl");

            // Extract the csdl, msl, and ssdl from the edmx so that they can be referenced in the connection string.
            ModelHelpers.WriteMetadataFiles(File.ReadAllText(@".\AdvancedPatterns.edmx"), @".\AdvancedPatterns");

            if (runInitializers)
            {
                using (var context = new AdvancedPatternsModelFirstContext())
                {
                    context.Database.Initialize(force: false);
                }

                using (var context = new MonsterModel())
                {
                    Database.SetInitializer(new DropCreateDatabaseAlways <MonsterModel>());
                    context.Database.Initialize(force: false);
                }
            }
        }
Esempio n. 2
0
        static SpatialTests()
        {
            const string prefix = "FunctionalTests.ProductivityApi.SpatialTvfsModel.";

            ResourceUtilities.CopyEmbeddedResourcesToCurrentDir(
                typeof(SpatialTests).Assembly(), prefix, /*overwrite*/ true,
                "226644SpatialModel.csdl", "226644SpatialModel.msl",
                "226644SpatialModel.ssdl");

            const string baseConnectionString =
                @"metadata=.\226644SpatialModel.csdl|.\226644SpatialModel.ssdl|.\226644SpatialModel.msl;
                                                  provider=System.Data.SqlClient;provider connection string='{0}'";

            _connectionString = String.Format(
                CultureInfo.InvariantCulture, baseConnectionString,
                SimpleConnectionString <SpatialNorthwindContext>());
        }