Let me clarify my scenario. I've got a WCF Service where uses a library, in this library exist the database model (edmx).
In my WCF Service:
[DataContract]
public class QuestionSetInformation
{
[DataMember]
public string Id { get; set; }
[DataMember]
public string SetName { get; set; }
[DataMember]
public string ObjectiveName { get; set; }
}
[ServiceContract]
public interface IService1
{
[OperationContract]
QuestionSetInformation[] GetQuestionSets(string objectiveName);
}
public QuestionSetInformation[] GetQuestionSets(string objectiveName)
{
var query = from r in QuestionRepositoryManager.GetRepositories()
select new QuestionSetInformation()
{
Id = r.Id,
SetName = r.SetName,
ObjectiveName = r.ObjectiveName
};
return query.ToArray();
}
As my library uses the EDMX, so I moved the connection strings to my WCF and it works PERFECTLY using the WCF Test Client. It delivers me what I'm expecting.
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ContosoDb" connectionString="metadata=res://*/Entities.Model1.csdl|res://*/Entities.Model1.ssdl|res://*/Entities.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=X;initial catalog=contoso2_db;persist security info=True;user id=X;password=X;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
But at a time using this WCF in a desktop application, I've got the following exception:
ServiceReference1.Service1Client service = new ServiceReference1.Service1Client("BasicHttpsBinding_IService1");
ServiceReference1.QuestionSetInformation[] qss = service.GetQuestionSets("something");
FaultException`1 was unhandled Code generated using the T4 templates for Database First and Model First development may not work correctly if used in Code First mode. To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application. To use these classes, that were generated from Database First or Model First, with Code First add any additional configuration using attributes or the DbModelBuilder API and then remove the code that throws this exception.
I have investigated this error in the web, everyone tells about a problem using the connection string but I supposed it's not the same case. I don't have idea about how to fix it