locked
How to create an .edmx file with <edmx:DataServices> node RRS feed

  • Question

  • Hi:

    I have created many Data Services with VS2010, However, none of them includes the <edmx:DataServices>, but <edmx:Runtime>.

    I searched MSDN and found following note:

    An .edmx file is automatically added to an application that references an ADO.NET Data Services service. In this case, the .edmx file contains an edmx:DataServices node, not an edmx:Runtime node. (http://msdn.microsoft.com/en-us/library/cc982042(v=VS.100).aspx)

    So How could I create an .edmx file with with <edmx:DataServices> node

    Kind Regards

    Wednesday, August 18, 2010 4:51 AM

Answers

All replies

  • Hi,

    I must admit I don't quite understand what you're looking for. I guess the first question to ask would be: What do you need the edmx file for?

    Each data service exposes its metadata as an edmx file. This can be retried when you issue a GET request to the service/$metadata endpoint. The response will be an edmx file with the DataServices element.

    Note that the implementation of the data service doesn't store this file anywhere. It is generated on the fly from the metadata model the service has. The way this model is built depends on the service. If your service is based on an EF mode, then it's more or a less a copy of the EF's model (but just the CSDL portion). If your service is based on reflection (in-memory objects), then it's built by reflecting over the classes you have. If your service is based on custom provider, then the IDataServiceMetadataProvider interface is used to determine the shape of the metadata and the model is built from that.

    In your client application, if you do Add Service Reference and point it to a data service, the VS will download the $metadata and store the response locally in your project. That's what the MSDN article talks about. Note that the file is not visible by default in the solution explorer, you have to turn on Show All files for it to show up. There should be no need to access this file. VS will generate client side proxy classes from it which is what your code is gonna be using. The edmx file is really just a cache for the VS tools.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, August 18, 2010 9:16 AM
    Moderator
  • Hi:

    Thanks for your answer, I have a question with what's the 'EF mode'

    Sorry I am a novice.

    Wednesday, August 18, 2010 11:14 AM
  • Hi,

    When you create a data service in VS you have a source file which defines a class derived from DataService<T>. The T in your case will be some context class. That class can either be an Entity Framework ObjectContext class, or a regular class with no base type. If it's the ObjectContext derived class, then you're using so called "EF provider". If it's a regular class with no base type, then you're using so called "reflection provider".

    There's a third way which doesn't look like the above which involves implementing the IDataServiceMetadataProvider interface, but I assume you're not using that.

    If your service uses the "EF provider", it means somehwere in your service project you will have an Entity Framework model (edmx file). This file contains the description of the data model (CSDL) along with a description of how it maps to the underlying database (SSDL, MDL, ...). If you create a data service using the "EF provider", then the $metadata response is pretty much the CSDL part of your underlying EF model repackaged in a new EDMX with the DataServices element around it.

    If your service uses the "reflectio provider", then there's no EDMX anywhere in your service project. You're exposing just in-memory objects. In that case the $metadata response is generated by the WCF Data Services runtime based of the shape of your classes wich are used to store the in-memory data (that's why it's called reflection provider).

    In any case: What do you need the EDMX file for in the first place?

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, August 18, 2010 11:25 AM
    Moderator
  • Thanks again.

    I have implemented with EF provider, It works all right.

    Now I want to implement service using 'reflection provider', How should I do?

    Could you please provide me some material to implement with 'reflection provider', It's better to simple.

     

    Thanks

    Wednesday, August 18, 2010 1:32 PM
    • Marked as answer by edhickey Thursday, September 9, 2010 5:36 PM
    Wednesday, August 18, 2010 1:52 PM
    Moderator