/// <summary>
        /// Get the OData metadata about the reliable collections from the reliable state manager using reflection.
        /// </summary>
        /// <param name="stateManager">Reliable state manager for the replica.</param>
        /// <returns>The OData metadata for this state manager.</returns>
        public static async Task <string> GetMetadataAsync(this IReliableStateManager stateManager)
        {
            // Build the OData model from the queryable types in the reliable state manager.
            var builder = new ODataConventionModelBuilder();

            foreach (var queryable in await stateManager.GetQueryableTypes().ConfigureAwait(false))
            {
                var qkey  = queryable.Key;
                var qkey2 = qkey.Replace('.', '#');
                Console.WriteLine(qkey2);
                dictEntityMap.Add(queryable.Key, qkey2);
                var entity = builder.AddEntity(queryable.Value);
                builder.AddEntitySet(qkey2, entity);
            }
            var model = builder.GetEdmModel();

            // Write the OData metadata document.
            using (var stream = new MemoryStream())
                using (var message = new InMemoryMessage {
                    Stream = stream
                })
                {
                    var settings = new ODataMessageWriterSettings();
                    var writer   = new ODataMessageWriter((IODataResponseMessage)message, settings, model);
                    writer.WriteMetadataDocument();
                    return(Encoding.UTF8.GetString(stream.ToArray()));
                }
        }