Exception while adding Dataset to EP page in AX2012

Can anyone help me resolve this issue.

I am creating a page in EP in AX 2012. In visual studio whenever i try to select the dataset i get this error:

Exception occurred on the metadata service on client or server. See exception details below:

Unable to log on to Microsoft Dynamics AX.

Here is the event log:

Unable to get version information using existing WCF configuration from local storage.

Exception details:

Microsoft.Dynamics.AX.Framework.Services.Client.MetadataServiceException: Exception occurred on the metadata service on client or server. See exception details below:

Unable to log on to Microsoft Dynamics AX. —> System.ServiceModel.FaultException: Unable to log on to Microsoft Dynamics AX.

Server stack trace:

at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)

at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

at Microsoft.Dynamics.AX.Framework.Services.Metadata.Service.IAxMetadataService.GetServicesVersionInformation(Guid versionId)

at Microsoft.Dynamics.AX.Framework.Services.Client.MetadataServiceClient.<>c__DisplayClassca.b__c7(IAxMetadataService channel)

at Microsoft.Dynamics.AX.Framework.Services.Client.ServiceClientHelper.InvokeChannelOperation[TResult,TChannel](IServiceClient1 client, Func2 operationInvoker, Func`2 exceptionWrapper)

— End of inner exception stack trace —

at Microsoft.Dynamics.AX.Framework.Services.Client.ServiceClientHelper.InvokeChannelOperation[TResult,TChannel](IServiceClient1 client, Func2 operationInvoker, Func`2 exceptionWrapper)

at Microsoft.Dynamics.AX.Framework.Services.Client.MetadataServiceClient.GetServicesVersionInformation(Guid versionId)

at Microsoft.Dynamics.AX.Framework.Services.Client.Configuration.ClientConfigurationInternal.GetClientConfiguration()