Search code examples
c#azurewindows-phone-8azure-mobile-servicesportable-class-library

Azure + PCL + WP8, is it possible to store ALL models in PCL?


I'm playing with Azure: i created a .net backend (so in my solution, i have PCL, Server, Wp8 projects) and i'd like to move all the models to PCL.

However, Backend's models are inherited from EntityData, which is a part of WindowsAzure.MobileServices.Backend.Entity.

The question is: should i include WindowsAzure.MobileServices.Backend to PCL, or should i leave Backend and PCL models separated?

EDIT: hm, just jumped into EntityData and now it says, its a part of WindowsAzure.Mobile.Service. That's better, but the question is the same: where the models should be stored?

EDIT2: tried to add Azure Mobile Services .NET Backend Entity Framework, and it wants to install tons of other stuff like AspNet.WebApi.Owin and AspNet.Razor into my PCL project. Seems not that good idea...


Solution

  • What I did was create aload DTO / View Models and stuck them in a PCL, obviously like you mentioned you cannot use certain types, so you create mappers on the server etc. I say leave them all separate and transfer basic types.

    I then share this between my web and mobile projects and can pass those objects back and forth freely and I think it works really well.

    One thing you might want to consider is versioning your models, as people will retain older versions of program perhaps (or you stop their service if they're out date).

    So I may have LoginModelV1, LoginModelV2 etc. And on the server you can choose to accept both with two functions or just the latest.