private EdmxFile ParseEdmx(EdmGenCommandLine cmdline)
        {
            EdmxFile edmx = new EdmxFile();
            XmlDocument doc = new XmlDocument();

            PollForCsdl(cmdline);

            doc.Load(Environment.CurrentDirectory + "\\" + cmdline.ProjectName + ".csdl");
            edmx.CSDLText = doc.SelectNodes("/")[0].ChildNodes[1].OuterXml;
            doc.Load(Environment.CurrentDirectory + "\\" + cmdline.ProjectName + ".ssdl");
            edmx.SSDLText = doc.SelectNodes("/")[0].ChildNodes[1].OuterXml;
            doc.Load(Environment.CurrentDirectory + "\\" + cmdline.ProjectName + ".msl");
            // Strip out the attributes that the designer gets all pissed about
            XmlNodeList list = doc.SelectNodes("/");
            foreach (XmlNode node in list[0].ChildNodes[1].ChildNodes[0].ChildNodes)
            {
                XmlAttribute es = node.Attributes["StoreEntitySet"];
                XmlAttribute name = node.Attributes["Name"];
                XmlAttribute type = node.Attributes["TypeName"];

                XmlNode typeNode = doc.CreateNode(XmlNodeType.Element, "EntityTypeMapping", "");
                XmlNode mapnode = doc.CreateNode(XmlNodeType.Element, "MappingFragment", "");
                mapnode.Attributes.Append(es);
                mapnode.InnerXml = node.InnerXml;
                foreach (XmlNode cNode in mapnode.ChildNodes)
                {
                    cNode.Attributes.Remove(cNode.Attributes["xmlns"]);
                }
                type.Value = string.Format("{0}.{1}", cmdline.ProjectName, es.Value);
                node.RemoveAll();
                node.Attributes.Append(name);
                typeNode.RemoveAll();
                typeNode.Attributes.Append(type);
                typeNode.AppendChild(mapnode);
                node.AppendChild(typeNode);
            }

            edmx.MSLText = doc.SelectNodes("/")[0].ChildNodes[1].OuterXml.Replace(" xmlns=\"\"","");
            return edmx;
        }
 private void WriteEdmxFile(EdmGenCommandLine cmdline, EdmxFile edmx)
 {
     using (StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + "\\" + cmdline.ProjectName + ".edmx", false))
     {
         sw.Write(edmx.TransformText());
         sw.Close();
     }
 }