J'écris mon premier service WCF. J'ai quelques opérations qui utilisent Entity Framework - saisissant certaines données et retournant la chaîne JSON.WCF avec EntityFramework
je peux appeler les opérations avec succès en utilisant le wcfClient, mais lorsque je tente d'invoquer l'opération dans ma propre application de la console de test j'obtiens l'erreur suivante dans le constructeur de modèle d'entité:
La connexion du nom spécifié est non trouvé dans la configuration, non destiné à être utilisé avec le fournisseur EntityClient, ou non valide. Code en classe DataContract:
[DataContract]
public class DrawSystemService : IDrawSystemService
{
public string GetDrawEntry(string entryId)
{
using (MyEntities context = new MyEntities())
{
tblDrawEntry drawEntry = null;
try
{
drawEntry = context.tblDrawEntries.FirstOrDefault(e => e.DrawEntryID == new Guid(entryId));
}
catch (Exception ex)
{
}
string json = JsonConvert.SerializeObject(drawEntry, Formatting.Indented);
return json;
}
}
}
code dans l'application de la console:
WcfDrawSystemLibrary.DrawSystemService drawSystem = new DrawSystemService();
drawSystem.GetDrawEntry("665B534B-73EE-4385-A9BA-02A25CB5FE4D");
attention à affiner cela - c'est-à-dire être plus précis – tom