src/Shared/EntityFramework/Internal/InternalConnection.cs
// <summary>
// Creates an <see cref="ObjectContext" /> from metadata in the connection.  This method must
// only be called if ConnectionHasModel returns true.
// </summary>
// <returns> The newly created context. </returns>
Creates an  from metadata in the connection.  This method must
only be called if ConnectionHasModel returns true.
Creates an from metadata in the connection . This method must only be called if ConnectionHasModel returns true .
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        public virtual ObjectContext CreateObjectContextFromConnectionModel()
        {
            Debug.Assert(UnderlyingConnection != null, "UnderlyingConnection should have been initialized before getting here.");
            Debug.Assert(UnderlyingConnection is EntityConnection, "Cannot create context from connection for non-EntityConnection.");
            var objectContext = new ObjectContext((EntityConnection)UnderlyingConnection);
            var containers = objectContext.MetadataWorkspace.GetItems<EntityContainer>(DataSpace.CSpace);
            if (containers.Count == 1)
            {
                objectContext.DefaultContainerName = containers.Single().Name;
            }
            return objectContext;
        }
[ SuppressMessage ( " " , " " ) ] public virtual ObjectContext CreateObjectContextFromConnectionModel ( ) { Debug . Assert ( UnderlyingConnection != null , " " ) ; Debug . Assert ( UnderlyingConnection is EntityConnection , " " ) ; var objectContext = new ObjectContext ( ( EntityConnection ) UnderlyingConnection ) ; var containers = objectContext . MetadataWorkspace . GetItems < EntityContainer > ( DataSpace . CSpace ) ; if ( containers . Count == 1 ) { objectContext . DefaultContainerName = containers . Single ( ) . Name ; } return objectContext ; }
Creates an  from metadata in the connection.
Creates an from metadata in the connection .
The newly created context.
The newly created context .