locked
Best Way To Use Entities in a Windows 8 Store App RRS feed

  • General discussion

  • Hello,

    I need some help on best practice for using entities in my windows 8 store app.  It appears that you can not add the entity framework directly into an WinRt app.  From what I have read you would have to consume a service.  How would you set up a service that would let me use entities from my database?

    Thanks,

    Bryan K.

    Monday, February 10, 2014 11:55 PM

All replies

  • Hello,

    I need some help on best practice for using entities in my windows 8 store app.  It appears that you can not add the entity framework directly into an WinRt app.  From what I have read you would have to consume a service.  How would you set up a service that would let me use entities from my database?

    Thanks,

    Bryan K.


    • Edited by Krossley Monday, February 10, 2014 6:39 PM
    • Merged by Fred BaoModerator Tuesday, February 11, 2014 5:35 AM Same Post
    Monday, February 10, 2014 3:55 PM
  • You would probably need to use some type of N-tier design pattern with separation of concerns of UI/BL/DAL pattern or UI/BLL/Repository pattern.

    EF would used at the DAL or Repository level.

    Tuesday, February 11, 2014 12:56 AM
  • Hello Krossley,

    >>How would you set up a service that would let me use entities from my database?

    The WCF Data Services should work well for this.

    For how to create the WCF Data Services for Windows Store Application, please refer to link below:

    http://blogs.msdn.com/b/mim/archive/2013/09/09/wcf-data-services-for-windows-store-applications.aspx

    There is a walkthrough in it and you can download the example.

    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.


    Tuesday, February 11, 2014 5:42 AM
    Moderator
  • Fred,

    I have downloaded the project but I get this error when I try to run it.

    Then I get this error in Visual Studio

    • Edited by Krossley Tuesday, February 11, 2014 2:37 PM
    Tuesday, February 11, 2014 2:36 PM
  • I need some help on how to turn this bit of code into async method.

            public   void GetValue()
            {
                var ctx = new CoinCatalogEntities(new Uri("http://localhost:54405/WcfDataService1.svc"));
                var query =  (from c in ctx.USsingle
                             select new USsingleResults()
                             {
                                 CoinID = c.CoinID,
                                 Checkbox = (bool)c.Checkbox,
                                 Year = c.Year,
                                 Description = c.Description,
                                 Type = c.Type,
                                 Value = c.Value,
                                 G = c.G,
                                 VG = c.VG,
                                 F = c.F,
                                 VF = c.VF,
                                 XF = c.XF,
                                 AU = c.AU,
                                 MS60 = c.MS60,
                                 MS63 = c.MS63,
                                 MS64 = c.MS64,
                                 MS64FB = c.MS64FB,
                                 MS65 = c.MS65,
                                 MS65FB = c.MS65FB
                             }).ToList<USsingleResults>();
    
    
                
    
                Value = query;
    
            }

    Tuesday, February 11, 2014 6:41 PM
  • I need some help on how to turn this bit of code into async method.

    Is this an Intranet or Internet solution where this application is going to be using a Restful  to a WCF Web service over HTTP with EF sitting behind the Restful service on another machine?

    If this is just a standalone application, then why are you using a Restful WCF Service?

    Tuesday, February 11, 2014 10:22 PM
  • Thanks for the reply.  My app use info from a Database that is update often.  The reason I am using WCF service is because I do not know of another way to connect to a database in a Windows Store App.  Is there another way?

    Thanks,

    Bryan

    Wednesday, February 12, 2014 2:59 PM
  • <copied>

    Windows 8 Metro style apps will not support connecting to a local database. That is to say, you will not be able to use a kind of connectionstring where you can say connect to server X. This has to do with the "Market store" principle that applications should work out of the box without configuring a database connection

    <end>

    I read this, and this is your roadblock. That kind of sucks. So it looks like you have to use a WFC Restful Data service that has EF on the backend sitting on the local machine or over the Intranet or Internet sitting on a remote machine.

    http://www.codeproject.com/Articles/234085/Fixing-WCF-to-build-highly-scalable-async-REST-API

    I also suggest that you post to this forum as well and start asking questions about WCF Data Service.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf

    Wednesday, February 12, 2014 6:15 PM