问题
As a disclaimer I warn that there may be malformed understandings going on here, hopefully not, but maybe.
The Situation:
There is an existing Windows VB Timesheet Application that deploys on customers Windows devices (not RT). This application creates a local SQL express store and synchronises with an Azure SQL DB via SQL data sync.
The Azure SQL DB further sychronises with a master DB (also via SQL data sync) that is stored locally where I am contracted, the master data is typically only changed in this master DB and the transactional data is what is synced up to azure.
The tables the application is working with are all under the dbo schema.
I am working on creating a Xamarin Forms mobile (iOS, WP8, Droid, and maybe winRT, using a PCL) version of the application (wordy, but you get the idea) that uses an Azure Mobile Service that points to the Azure SQL DB. It only uses a subset of the features as of now.
The Problem:
Now the problem (as it may be obvious already) is that I need access to most of the tables, of which are under the dbo schema, and I was hoping / wondering what the best practice would be to solve this.
If I could point my Azure Mobile Service to use the dbo schema and give the generated login the appropriate privileges manually / scripted. This is needed for my migration of the tables to include the required system properties an so fourth.
Another proposition would be to add the system columns required for azure mobile services sync operations to the master db, push them up to the azure db and then create views of all the required data in the mobile services schema. I do not yet know if this would result in any limitations to the service.
There is always of course the option of moving all the data to a schema other than dbo - however this requires extension work on the other systems, which may consume considerable time particularly due to my unfamiliarity with them.
Any relevant information, discussion or advice would be thoroughly appreciated.
回答1:
Probably your best option is to create the Azure Mobile Services system properties to your database. On Azure Mobile Services, there are five specific fields you need:
- id - should be a unique string - good idea to use a GUID here
- __version - let AMS handle this, default/null allowed
- __createdAt - generally auto-generated at the SQL Server on insert
- __updatedAt - let AMS handle this
- __deleted - should be false unless the record is deleted (soft-delete support)
These are all defined in the EntityData class in the .NET SDK. You can do a one-time set of the values for your existing records and then let the AMS SDK handle it from then on.
来源:https://stackoverflow.com/questions/32899672/azure-mobile-services-with-existing-database-without-schema-changes