I have a local database I am working on for a website, I can publish the website changes to azure but cannot see an easy way to just get my 'changes' pushed up to SQL Azure.
I used this https://sqlazuremw.codeplex.com/ to initially get my local database onto Azure, but it seems to only support entire database migrations. Not minor changes like data, or a new field added?
This is my first time using Azure and it seems great, it's just this issue with the database which is now putting me off slightly.
I'm afraid that without any third-party tool you will not be able to achieve much.
What I usually do is create migration sql scripts and run them directly against the production database after the scripts have been thoroughly tested
If you manage your database schema using Visual Studio Database project then you can sync it with the SQL Azure database. I believe you can also sync data but I have not used that.
Related
I have an ASP MVC 5 application using Code First EF. I am setting up an environment to debug on a remote machine and follow these steps.
The website itself publishes fine, but I'm needing to publish the EF local databases along with it as well, content included. I've been digging around online but have had difficulty finding a step-by-step process for doing this that also allows for EF code first updates to the remote database.
Any help would be appreciated.
As for connection , try modifying the connection string in webConfig. As for the information, I'm not 100% sure on this, but I'd you think you would be able to backup the database and restore on the remote machine.
There is a _migrationHistory table in the database that EF refers to when checking the models against the database, so by restoring the whole database (and the _table as the result ) EF should not lose its state ( you won't need to run Update-Database).
If you publish to a server, you can use different appsettings for development and production using different web.config-files as described here
And for your database:
I pretend you want some content of your database being transferred into the production database in addition to get the right structure of tables too.
In this case, Migrations could do the job:
If you create your database with CodeFirstMigrations you can be sure, that your structure is right, by migrating the database before publishing.
And for the data, you can use a Database-Initializer to get the required data into any database your targeting as long you have enough permission for this.
I want to easily migrate my existing DB to Azure hosting. In my project I use Entity Framework DB First. Is there any lessons or examples of how to do that?
What database are you using Locally. if you're using SQL2012 or (2012 Express) there is tooling built into Management studio to allow you to Import/Export between local and azure.
Have a look at Import Data Tier Application & Export Data Tier Application for generating BACPAC files (SQL Azure equivalent of a .bak). That'll allow you to get your initial DB into SQL Azure. And to get backups back to your local environment in future.
Once you've done that, take a look at the Fluent Migrator for pushing DB First schema changes you develop locally out to your QA & Produciton Databases in azure.
You can also do this:
Go to the Azure Management portal, click on "Databases", choose your server, click on "Configure" and give permission to your local IP to connect directly to the DB.
Go back to your solution, and change the entry for the connection string on your web.config file to point to the azure server.
Run "database-upgrade" from the package manager (powershell) command line to perform all migrations on the server
You can also configure your publishing profile to include the migrations on each deploy for azure. Take a look at a previous question on that subject here
I'm working on a program that will work very nicely with a database structure and using mysql. I could easy do this with a common server and common database. However I'm looking for a way to have my client(s) use the program on an offline machine without having to install any database managing software.
Basically I want the installation to set up the necessary tables on their machine and have them fill in the database with information relevant to them. Before I start though I wanted to know if this was possible to connect to and manage a database through a C# application with out installing sql software.
You could consider using SQL Server Compact Edition.
SQLite is another option.
Both of these can be deployed with your application and need no separate configuration.
Yes. It is possible. How to do it exactly depends on the database connection approach you're using. For example, this approach shows how to use DataReaders. That's a very old approach. Modern approaches are recommended to use LINQ to SQL, which can be configured to access remotely by setting up a DataContext to point to an external resource.
Basically, wherever you can define a connection string to connect to a DB, you can make that string point locally or externally. An external resource must obviously be available through some URL in order to connect, of course.
You can not connect to a mysql database without installing mysql.
However you can use in process database like sqlite or Compact SQL. They are not traditional server, but rather a library that keeps the database in a local file.
I've built a Compact Framework application to be used by delivery drivers. The system includes a WCF Service and SQL database on the server as well as a SQL CE database and CF application running on the mobile device.
Now the question is how to I update all this easily when I release new versions? The problems are:
it may be deployed to hundreds of PDAs
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
the WCF service code will need to be updated
the SQL database schema will need to be updated
I can see solutions to all this but it seems like a lot of work. I thought it may be helpful to get a few tips before I launch into it all.
Thanks a lot
Mark
I've done some projects with more or less the same requierements.
it may be deployed to hundreds of PDAs
I'll recommend to use an updater, within the application. It checks via a webservice the availability of a new version. Download if theres an update. Then run another process to perform the update(This process I only use to run wceload.exe and then reboot the device).
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
Don't include your database as a file for the application, create the scripts and check if the db exists if not create the db.
the WCF service code will need to be updated
I have an update webservice which is independent so the contract wont change. Which receives the current version, authentication and returns if the update is available and the url for the file to download.
You will need two different address to update and keep the other part working.Just perform a redirect in the new version.
the SQL database schema will need to be updated
I hope you mean that you refer to the server backend so I recommend to use views to search for the information.
If you mean to the SQLCE db you can ship patching scripts or plain erase the db and recreate the db.
I need to access and download data from a MySQL database without connecting to the database during development in VisualStudio. Is there a way to program it blindly (since I know what the database looks like) like its done in PHP?
Alternatively, can I use download the database schema and use it in Visual Studio?
What do you mean?
Even if you can't connect to the live database during dev time, you can create your own local testing MySQL database and connect to that.
You could write sql and use sql connection, and just mock out the database so that your testing will still work, as long as your mock returns what is expected.
Though I agree that creating your own local database would be best.