locked
Strange “ContainerNamespace is null or empty” error from [WCF Data Service 5.7] and [Entity Framework 6.1.3] RRS feed

  • Question

  • I want to retrive data from my database using WCF Data Service 5.7 and and Entity Framework 6.1.3 against MS SQL 2014 in a normal ASP.NET website.

    First, I made sure that I am using:

    1- Microsoft.OData.EntityFrameworkProvider 1.0.0-beta2 from NuGet Package Manager.

    2- Use EntityFrameworkDataService instead of DataService

    3- I set config.SetEntitySetAccessRule("*", EntitySetRights.All);

    The problem:

    1- When I request list of entities as a URL from the data service as the following: localhost:12671/MovieReviewsService.svc

    I got normal XML list of entities as usual, but without the XML header and namespaces as shown in the next snapshot: list_of_entities

    2- When I try to return list of entities (for example, list of Movies) using the following URL: localhost:12671/MovieReviewsService.svc/Movies

    I got this error in the soapshot: (The value returned by IDataServiceMetadataProvider.ContainerNamespace must not be null or empty). the_error_when_trying_to_return_Moviews_or_Reviews_XML

    The code of Data Service:

    [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class MovieReviewsService : EntityFrameworkDataService<MovieReviewsEntities>
    {
       public static void InitializeService(DataServiceConfiguration config)
       {
          config.SetEntitySetAccessRule("*", EntitySetRights.All);
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
          config.UseVerboseErrors = true;
       }
    }

    Project Sample: (from my OneDrive) 

    My MoiveReviews WCF Data Service Sample Project

    MS SQL (database and data) file for MovieReviewsDatabase: (from my OneDrive) 

    Movies Reviews Database .SQL File

    Edit:

    Thanks for reply.

    I have just tried change the project from normal asp.net to web application, and it works.

    But that is weird !

    • Edited by khalednet85 Saturday, February 27, 2016 9:59 AM Tried Web Application instead of normal ASP.NET website
    Saturday, February 27, 2016 7:33 AM

All replies

  • I want to retrive data from my database using WCF Data Service 5.7 and and Entity Framework 6.1.3 against MS SQL 2014 in a normal ASP.NET website.

    First, I made sure that I am using:

    1- Microsoft.OData.EntityFrameworkProvider 1.0.0-beta2 from NuGet Package Manager.

    2- Use EntityFrameworkDataService instead of DataService

    3- I set config.SetEntitySetAccessRule("*", EntitySetRights.All);

    The problem:

    1- When I request list of entities as a URL from the data service as the following: localhost:12671/MovieReviewsService.svc

    I got normal XML list of entities as usual, but without the XML header and namespaces as shown in the next snapshot: list_of_entities

    2- When I try to return list of entities (for example, list of Movies) using the following URL: localhost:12671/MovieReviewsService.svc/Movies

    I got this error in the soapshot: (The value returned by IDataServiceMetadataProvider.ContainerNamespace must not be null or empty). the_error_when_trying_to_return_Moviews_or_Reviews_XML

    The code of Data Service:

    [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class MovieReviewsService : EntityFrameworkDataService<MovieReviewsEntities>
    {
       public static void InitializeService(DataServiceConfiguration config)
       {
          config.SetEntitySetAccessRule("*", EntitySetRights.All);
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
          config.UseVerboseErrors = true;
       }
    }

    Project Sample: (from my OneDrive) 

    My MoiveReviews WCF Data Service Sample Project

    MS SQL (database and data) file for MovieReviewsDatabase: (from my OneDrive) 

    Movies Reviews Database .SQL File




    Friday, February 26, 2016 7:48 PM
  • One learns not to use EF directly by any type  of service and leave the EF entitles behind and send DTO(s).

    https://en.wikipedia.org/wiki/Data_transfer_object

    That's why there are solutions like what is in the link.

    https://entitiestodtos.codeplex.com/

    You'll get better support at the below forum.

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetdataservices

    Saturday, February 27, 2016 1:46 AM
  • Thanks for reply.

    I think I have a clue.

    If I change the project from normal asp.net to web application, it works. But that is weird !

    Saturday, February 27, 2016 9:57 AM