Update database from model - Entity Framework - sql

Is it possible in any way to just update the database schema from entity model..? So that all the information in the database stays in the database? When you generate database from model the information will get lost.. I work against SQL Azure, and I have not found any tool to manage the tables and realations in the SQL Azure database in a proper way.. It would be soo nice if it could be done by the Entity Framework designer.

I think this will be resolved (from an entity framework point of view) in the next EF release.
From an azure point of view you can use SQL Azure Migration Wizard.

Related

Populating data from legacy DB using Entity Framework Code First

Basically we are doing a revamp of an old website so we've set up a new application/DB with proper relational schema but we need to bring data over from old system (invalid referential integrity/no fk/sometimes no pk) as each of us work on a module.
Looking at using EF code first as there will be a few of us working on the system.
Will it be best to write SQL script to bring over all these tables to fit the new schema or is there a good way to do this in Code First? like seeding?
Or will this case be suited to going Database First approach where we just bring over data using Generate Script functionality in SSMS?
Would like to hear if anyone's done similar work. Thanks in advance.
A one-time migration from the old schema to the new schema would normally be done with SQL scripts, not with EF. You have to write the transformation logic either way, and with EF you additionally have to create a DbContext model for the old schema, and EF is slower at performing bulk operations.
I had a similar task to do: I had to create a completely new web application (App B) with a new database (Db B) based on old ones (App A and Db A). The relations and general structure was a real mess in Db A, so I decided that it was better to generate Db B with a code-first approach and then I created another simple application which would do all the migration stuff. I had 2 contexts from Db A and Db B and all the migration logic was there. It worked like a charm.
As for seeding. It would be better if I could do it with a db seeder in the App B but there was a huge amount of data so it was literally impossible to do that.

Create Table in Azure SQL Server for mobile services (.net Backend)

I am creating table in Azure SQL Server using mobile services webservice (.net backend). But table is not created in SQL Server.
My questions are:
Can I create table manually in Azure SQL Server?
If I can create table then there will any possibility of error?
Is there any possibility to find out why table is not creating?
Please provide your suggestions how to solve this
If you are using the .NET backend, you are operating in Entity Framework for table management. You will likely need to do an EF Migration to create the table - there is no dynamic schema / table maintenance. It's best to learn Entity Framework and go from there.
Specifically:
1) Yes, you can create the table manually in the SQL Management Studio.
2) You will need to define the appropriate table within your .NET backend as well. The schema must match what is expected. You can't just take any old table and expect it to work
3) You can turn on logging in the Entity Framework and see the underlying SQL statements and errors being returned by SQL Server. However, your problem is likely to be because Entity Framework hasn't run a migration.
Thanks for your answer.
Table has created by using mobile services.
Actually table has been created by using mobile services but it was not displaying in sql server. To display table in sqlserver i have to do action (like insert,update data) in atleast one table. then all table display.
Yes you can. If you use Mobile Services, go to the dashboard and Configure - here, you will see the database server link. Go to that, and get the connection string. Then, you can connect with something like, for example, SQL Server Management Studio 2014 (i would recommend to do that to avoid any support inconsistencies) and do what you want with the database (with some limitations, however). You may do that using Visual Studio as well.
If you use Mobile Apps, go to the Mobile App dashboard, then Data Connections - here, you will see the hidden connection string that you can use for connecting the same way as described above.

Azure Create Database In Code

I have a prototype paas (platform as a service). The solution currently saves data for all customers in a single sql instance. For now this is fine, but I worry about slowdowns when the db grows. I reason I could keep the service running fast if each customer had their own database.
I was looking on the Azure portal and I found nothing. I can easily create a new database manually - but - I don't want that, I want to keep everything automated. Is there a way I can setup a sql server 'group' ?
While I am at it, SQL is not a requirement. My data is noSQL ready. Is this something I could do with monogoDB running on a worker role ? me.
You should look at the Azure DocumentDb preview, which is a NoSQL database provided as a managed service.
There is a Azure SQL Managment Nuget
http://www.nuget.org/packages/Microsoft.WindowsAzure.Management.Sql
http://www.bradygaster.com/post/managing-windows-azure-sql-databases-using-the-management-libraries-for-net

SQL Azure Data Sync service and schema update (Visual Studio Schema Compare)

I have a local SQL database (database first EF application) and an Azure database which are synced by the azure data sync service.
Now what do I have to do to when I update the local schema of an table? Of course I have to update the schema in the sync service but that is not enough. The schema of the azure database isn't updated by the sync service itself.
Before I used azure data sync I could simply call the sql schema compare from Visual Studio but now there are so many new tables that I don't know what to update and what not.
When I update the azure database manually with the management portal the sync does work. But isn't this also possible via Visual Studio schema compare (or SQL SMMS)?
i think you already answered your own question, you said you could do it via VS except that there's too many new tables.
just skip any object that has a DSS prefix to it, those are used by SQL Azure Data Sync Service.
but as you already mentioned, you still have to edit the dataset definition in your Data Sync Service sync group.

Apply Master Data Services to an existing SQL database

I'm familiar with creating MDS databases once MDS is installed, but is it possible to install/enable/configure MDS for databases that existed prior to the installation of MDS?
I am unaware of any way to "apply" MDS to an existing database. A possible migration strategy is to recreate the database schema as an MDS model and use the entity based staging feature to migrate data from the original database to the MDS model. Here's a primer on EBS and how it works: http://msdn.microsoft.com/en-us/sqlserver/hh802433.aspx.