IDataServiceMetadataProvider Entities Missing in $metadata

Posted on | 87 words | ~1 min
WCF Data Services

If you are following through the example on creating custom data service providers as on this blog:

http://blogs.msdn.com/b/alexj/archive/2010/01/08/creating-a-data-service-provider-part-3-metadata.aspx

And you notice that your entities are not showing up in the $metadata file, double check that you have added this:

public class service : MyNewDataService
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }
Just remember to set the entity set access rules for all entities - other they won't show up!