GenerateStoreMetadata with filters generates empty model

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Posts: 6
Joined: Wed 18 Mar 2009 09:53

GenerateStoreMetadata with filters generates empty model

Post by _andreas » Mon 23 Mar 2009 08:41


I currently evaluate dotConnect with Entity Framework. I use dotConnect Beta

I am trying to generate a edmx file from an oracle database. If i use GenerateStoreMetadata without filters, it works perfectly. However, if I use a filter to select only a few tables, GenerateStoreMetadata creates an empty edmx. Fruthermore there is no exception thrown.

The selected tables exsist because if I insert into the filter a table which does not exsist an exception is thrown.

The Method LoadFilter() loads the tablenames from the app.config.
In the Main() Method the generation of ssdl, msl and csdl happens.

Code: Select all

        private static IEnumerable LoadFilter()
            IList entries = new List();

            XmlDocument doc = new XmlDocument();
            XmlNodeList nodes = doc.SelectSingleNode("tables").SelectNodes("table");
            if (nodes.Count > 0)
                foreach (XmlElement elm in nodes)
                    entries.Add(new EntityStoreSchemaFilterEntry(null, null, elm.Attributes["name"].Value));


            return entries;

static void Main(string[] args)
            IList ssdlErrors = null;
            IList csdlAndMslErrors = null;

            IEnumerable filters = LoadFilter();

            // generate the SSDL
            string ssdlNamespace = storeName + "Model.Store";
            EntityStoreSchemaGenerator essg =
                new EntityStoreSchemaGenerator(
                    oracleProvider, ConfigurationManager.ConnectionStrings["oracle"].ConnectionString, ssdlNamespace);
           ssdlErrors = essg.GenerateStoreMetadata(filters);

            // write out errors
            if ((ssdlErrors != null && ssdlErrors.Count > 0))
                System.Console.WriteLine("Errors occurred during generation:");

            // write the SSDL to a string
            StringWriter ssdl = new StringWriter();
            XmlWriter ssdlxw = XmlWriter.Create(ssdl);

            // generate the CSDL
            string csdlNamespace = storeName + "Model";
            string csdlEntityContainerName = storeName + "Entities";
            EntityModelSchemaGenerator emsg =
                new EntityModelSchemaGenerator(
                    essg.EntityContainer, csdlNamespace, csdlEntityContainerName);
            csdlAndMslErrors = emsg.GenerateMetadata();

            // write out errors
            if (csdlAndMslErrors != null && csdlAndMslErrors.Count > 0)
                System.Console.WriteLine("Errors occurred during generation:");

            // write CSDL to a string
            StringWriter csdl = new StringWriter();
            XmlWriter csdlxw = XmlWriter.Create(csdl);

            // write MSL to a string
            StringWriter msl = new StringWriter();
            XmlWriter mslxw = XmlWriter.Create(msl);

            // write csdl, ssdl & msl to the EDMX file
                csdl.ToString(), ssdl.ToString(), msl.ToString(), new FileInfo(
                    "test" + ".edmx"));

Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 23 Mar 2009 12:10

It would better if you had mentioned that your project uses EdmGen2 project.
Anyway, the problem is associated with wrong (empty) schema name.
The correct way for adding filter is like the following:

Code: Select all

entries.Add(new EntityStoreSchemaFilterEntry("", "", elm.Attributes["name"].Value));
Please note that if you set catalog name to null you encounter an "Unexpected parameter count" error.

Post Reply