locked
WCF with Entity Framwork 6 RRS feed

  • Question

  • Dear , 

    I'm create WCF project with Entity Framework 6.0 and using windows form to call this WCF Service . 

    if Unity has objects without relation  project work correct , but if entity has relation between object give me the following error and don't find any solution for this error .

    An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll
    
    Additional information: An error occurred while receiving the HTTP response to http://localhost:25297/Service1.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server


    Please help me .


    Regards & Thanks.

    Saturday, June 21, 2014 9:00 AM

Answers

  • Is the error caused by disabling Lazy loading? If so and your query requires returning multiple tables you will need to use the Include method in the query otherwise the relationship will not be loaded.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Sunday, June 22, 2014 7:13 PM

All replies

  • Try turning off Lazy Loading if you have not done so already. I believe this may be the issue.

    DbContextInstance.Configuration.LazyLoadingEnabled = false;


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Saturday, June 21, 2014 1:03 PM
  • This sounds to me like you have a WCF binding issue.
    Saturday, June 21, 2014 8:32 PM
  • I'm try this but give me the following error 

    An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll
    
    Additional information: Schema specified is not valid. Errors: 
    
    The relationship 'MYAPP.FK_Custodian_Employee' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.
    
    
    
    
    
    The relationship 'MYAPP.FK_Custodian_Employee1' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.
    
    
    
    
    
    The relationship 'MYAPP.FK_Employee_Job' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.
    
    
    
    
    
    The relationship 'MYAPP.FK_Job_Employee' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.
    
    
    
    
    
    The relationship 'MYAPP.FK_Job_Employee1' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.
    
    
    
    
    
    The relationship 'MYAPP.FK_Role_Employee' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.
    
    
    
    
    
    The relationship 'MYAPP.FK_Role_Employee1' was not loaded because the type 'MYAPP.Employee' is not available.
    
    The following information may be useful in resolving the previous error:
    
    The required property 'Branch' does not exist on the type 'DAL.Employee'.


    Regards & Thanks.

    Sunday, June 22, 2014 7:18 AM
  • Is the error caused by disabling Lazy loading? If so and your query requires returning multiple tables you will need to use the Include method in the query otherwise the relationship will not be loaded.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Sunday, June 22, 2014 7:13 PM
  • Hello,

    I once solve this error by setting the DbContext.Configuration.ProxyCreationEnabled = false or returning a DTO class rather than the entity class, I think the created proxy class is incompatible with the client side type.

    You can have a try and if this also not work for you, could you please share some code with us?

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, June 23, 2014 7:09 AM