Xamarin Development – Web API vs Entity Framework with Repository Pattern

cross platformentity-frameworkmobileweb-apixamarin

My team currently has a WPF application that runs on PC just fine. It utilizes Entity Framework 6 with the Repository/Unit of Work pattern that talks to Azure for the database store.

We service a little over 300 clients currently. But, we're wanting to expand our footprint for the app and transition to mobile devices. Our goal is to leverage Xamarin to do all the cross platform work and still keep all of our C# logic. First Universal Windows Platform, then Apple or Android, but all 3 eventually.

My question is: Do we need to transition to a Web API based call to the database to support cross platform? Is there any reason we should get away from Entity Framework? Is it less secure/reliable for the activities we'll be doing? Can we at least keep Entity Framework for the Universal Windows Platform?

Most cross platform devs I meet are not C# devs, so they always say you gotta have the web API but I'm a bit stuck on the WHY.

Best Answer

Do we need to transition to a Web API based call to the database to support cross platform?

Yes.

Here's why: you'll need a common, web-enabled API for your three front-ends to talk to. Entity Framework won't execute queries to your DB server over the Internet.

Is there any reason we should get away from Entity Framework?

No. You can use it to build the Web API. You can even retain your Repository/Unit of Work layers, if you want to. Here's what your architecture might conceptually look like:

DB <--> Entity Framework <--> Repository/UOW <--> Web API Endpoint <==> Frontend
                                                                    ^
                                                                    JSON over Internet