Example #1
0
        public void Migrations_or_Edmx_writing_throws_when_model_is_not_cached()
        {
            try
            {
                var fileName = _location + typeof(NonCachedContext).FullName + ".edmx";

                using (var context = new NonCachedContext())
                {
                    using (var writer = XmlWriter.Create(fileName))
                    {
                        EdmxWriter.WriteEdmx(context, writer);
                    }
                }

                using (var reader = XmlReader.Create(fileName))
                {
                    var compiledModel = EdmxReader.Read(reader, "default");

                    using (var context = new NonCachedContext(compiledModel))
                    {
                        using (var xmlWriter = XmlWriter.Create(new MemoryStream()))
                        {
                            Assert.Throws <NotSupportedException>(
                                () => EdmxWriter.WriteEdmx(context, xmlWriter));
                        }
                    }
                }
            }
            finally //clean up
            {
                MutableResolver.ClearResolvers();
                if (File.Exists(_location + typeof(NonCachedContext).FullName + ".edmx"))
                {
                    File.Delete(_location + typeof(NonCachedContext).FullName + ".edmx");
                }
            }
        }