Can Azure Mobile Services Offline Sync be used with Entity Framework Core?

azure-mobile-services entity-framework-core uwp

Question

How to use the managed client for Azure Mobile Apps seems to operate on table entities rather than the POCO classes we use in EF. We have a business application that we are trying to port to UWP. We have complex related data and are used to being able to edit multiple entities in the object graph and have them persisted with dbContext.SaveChanges(). However the docs referred to show changes saved on a table by table basis.

Is it the case that we must choose between using either EF Core or using Azure Mobile Services Offline Sync? Is there sample code showing EF Core being used with Azure Mobile Services Offline Sync?

1
1
5/5/2017 5:26:19 AM

Popular Answer

From what I can surmise from my research, the integration between a mobileservicesqlitestore and dbcontext has not been done ... YET! Both of these contexts require a POCO to be registered with the framework.

For EF, the POCO must be registered within a DBContext as a DBSet (or have it derived from the POCO) to be "managed" by EF for the goodness of change tracking, navigation properties etc.

For MobileServiceSQLLiteStore, tables are registered for offline sync via

  var store = new MobileServiceSQLiteStore"localsync.db");
store.DefineTable<TodoItem>();

These are two different frameworks that are used to two different purposes. EF (via EF Core) is my preferred means of managing data on mobile devices (android, Uwp, and IOS (?-not yet there)). MobileServiceSQLStore needs to manage the POCO to record what changes are being done in order to manage those changes, but cannot handle the complexities of an object graph.

IMO, what needs to happen, is to hook into EF events for CRUD activity. This is one of the main purposes of EF is to track changes across the EF graph, and hold them until a Save on the context is done. When a SAVE occurs, these changes are enumerated, and executed with the underlying provider - SQLLite, SQL Server, etc.

What we need is MobileServiceSQLStore provider for EF that takes the CRUD activity of EF and pushes these changes held within that context through the requirements of MobileServiceSQLStore.

Something that I would love to work on... but first I have to get more familiar with MobileServiceSQLStore...

I know it's not complete answer, and may not be 100% correct, but I'm looking for 1) validation if this is the path to proceed with, and 2) who is interested in helping.

More URL on creating a provider for EF:

https://blog.oneunicorn.com/2016/11/11/so-you-want-to-write-an-ef-core-provider/

https://docs.microsoft.com/en-us/ef/core/providers/writing-a-provider

2
7/14/2017 2:38:41 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow