private EntityFramework CreateEntityFrameworkFromDocs()
        {
            EntityFramework edmx = new EntityFramework();

            if (!string.IsNullOrEmpty(options.SourceMetadataPath))
            {
                try
                {
                    if (!System.IO.File.Exists(options.SourceMetadataPath))
                    {
                        throw new System.IO.FileNotFoundException($"Unable to locate source file: {options.SourceMetadataPath}");
                    }

                    using (System.IO.FileStream stream = new System.IO.FileStream(options.SourceMetadataPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                    {
                        if (options.Formats.HasFlag(MetadataFormat.EdmxInput))
                        {
                            edmx = ODataParser.Deserialize <EntityFramework>(stream);
                        }
                        else if (options.Formats.HasFlag(MetadataFormat.SchemaInput))
                        {
                            var schema = ODataParser.Deserialize <Schema>(stream);
                            edmx = new EntityFramework();
                            edmx.DataServices.Schemas.Add(schema);
                        }
                        else
                        {
                            throw new InvalidOperationException("Source file was specified but no format for source file was provided.");
                        }
                    }
                    if (options.Namespaces != null && options.Namespaces.Any())
                    {
                        var schemas = edmx.DataServices.Schemas.ToArray();
                        foreach (var s in schemas)
                        {
                            if (!options.Namespaces.Contains(s.Namespace))
                            {
                                edmx.DataServices.Schemas.Remove(s);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Unable to deserialize source template file: {ex.Message}");
                    if (ex.InnerException != null)
                    {
                        Console.WriteLine($"{ex.InnerException.Message}");
                    }
                    return(null);
                }
            }

            bool generateNewElements = !options.SkipMetadataGeneration;

            // Add resources
            if (Documents.Files.Any())
            {
                foreach (var resource in Documents.Resources)
                {
                    var targetSchema = FindOrCreateSchemaForNamespace(resource.Name.NamespaceOnly(), edmx, generateNewElements: generateNewElements);
                    if (targetSchema != null)
                    {
                        AddResourceToSchema(targetSchema, resource, edmx, generateNewElements: generateNewElements);
                    }
                }

                // Figure out the EntityCollection
                this.BuildEntityContainer(edmx, options.BaseUrl);

                // Add actions to the collection
                this.ProcessRestRequestPaths(edmx, options.BaseUrl);
            }

            return(edmx);
        }