Free SQL Server in Azure - sql-server

I'm creating a MVC 5 web application with EF 6 Code first. Now it creates a database in the App_Data folder. I want to publish the website to an Azure website. Because this is only the test version of the website, I don't want to pay for it. It will only visited a couple of times a month until it is in production.
Is it possible to run the database something like an access database file? I thought that some kind of functionality existed. I thought the name was SQL Server Compact Edition? But how does it works?
I also thought that you could create a free 20MB sql server database. See this link of the pricing page. Search for 20 in your browser.
http://azure.microsoft.com/en-us/pricing/details/web-sites/
I don't see that option.
Any ideas would be welcome!

Yes, you just have to right click and include in your project.
I write an article for this in Chinese, and this is the English version I found.
Solution for free SQL Server in Azure:
Install two nuget: EntityFrame.SqlServerCompact & Microsoft SQL Server Compact Edition
Put SQL database file (.sdf/.mdf) in APP_Data folder
Put connection string like this to use it:
<add name ="DefaultConnection" connectionString ="Data Source=|DataDirectory|CompactDB.sdf" providerName ="System.Data.SqlServerCe.4.0" />
Publish full project include above SQL database file to AzureWebsites.
It work well and is totally free.

I found the 20Mb free SQL Server option. I still had a website in my subscription that was stopped. When I deleted that, no website or database was there in my subscription anymore. I then created a new website via the custom website option in the azure portal. I then could select (in the wizard) a free 20 MB SQL Server database.
I uploaded my MVC application and the Code First created my database automatically. I don't know why the option wasn't showing up before but now it works.

There's no free version of the SQL Database service. What you may have read is that there's a 1 year free 20MB MySQL database available.
When you're saying that a database it created in the App_Data folder, this uses SQL Server Compact (see Maresh's links) and that is free.

If you want to connect on premise database you need to setup azure virtual network. See the codeproject article
http://www.codeproject.com/Articles/261063/Azure-Virtual-Network-Connecting-Local-Database
there is some alternative way using azure service bus.
http://www.bradygaster.com/post/windowsazurewebsites-onprem-servicebus
Another option would be sql server compact edition.
http://msdn.microsoft.com/en-us/data/ff687142.aspx
see below link also
Support for SQL Server Compact 4.0 on Azure

Related

Server Objects not available in SQL Server Management Studio

I spun up an Azure SQL Database and connected to it using SSMS in hopes of following this tutorial. When I look in Object Explorer, the only two folders I see are "Databases" and "Security"; there is no "Server Objects", and for the life of me, I cannot figure out why not.
Available Folders
Is it an Azure SQL Database thing? Thank you in advance for any help you can provide!
Azure SQL Database only allows database access. Server Objects is something you need access to the entire instance/server. If you want to use Azure, you'll need to spin up a VM and install SQL Server on there in order to follow this tutorial.
From the pictures in the tutorial it looks like they have SQL Server Express running on their local machine. If you can, try that route as it'll probably be cheaper and less hassle.

Browsing an Entity Framework code-first database + Azure Dev Fabric

I have a database created using the code-first approach against SQL Server Express. I'm trying to view the database in Management Studio, but cannot find the database. VS Database Explorer also cannot seem to find it.
I've searched about but cannot find any reference to what I'm after. Is it possible to browse a database running in the dev fabric?
Usually if we create a new database in Visual Studio, it will give us a database file, but it won’t register the database in SQL Server Management Studio. So please manually attach the database file to SQL Server Management Studio. First please find the database file, normally it is under the AppData folder of our project. Then I would like to suggest you to check http://msdn.microsoft.com/en-us/library/ms190209.aspx for instructions on how to attach the database.
Best Regards,
Ming Xu.
Take a look at Scott Gu's blog post on EF Code First and DB Generation: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
The Azure Dev Fabric has nothing to do with the DB layer, the connection string handles all this for you i.e. when you deploy to SQL Azure your DB will go there, the only thing that needs changed is the connection string...from localhost (Dev Machine) to SQL Azure connectionn string
HTH

How to set up Database for ASP.NET MVC Application

I created an data driven ASP.NET MVC Application locally and it works fine. Within my App_Data Folder of my project i see two databases: ASPNETDB.mdf and myProjectDatabase.mdf.
I uploaded my project files an the webserver, so that I can actually open the website. But I couldn't figure out how to connect my Database that I created locally to that website. My Website uses Authentication so that it is necessary that a user logs in/registers. But because the database is not connected this obviously doesn't work, because the application needs a database to save and retrieve user information.
I'm using Visual Studio 2010 Express and downloaded Microsoft SQL Server Management Studio as well to work with my database. With Microsoft SQL Server Management Studio I already connected to my database with the login information my provider gave me. But how can I import my local databases? Do I need to import ASPNETDB.mdf as well, because that is where the user information are stored?
I would be very thankful for help
What version of SQL Server do you have on your production server? SQL Server Express can attach to those local MDF files. If you're using SQL Server Standard, you'll need to attach them to the SQL Process.
Also, the ASPNETDB.MDB file is the authentication database that is automatically created in your MVC project. That is the DB that stores usernames and passwords, so yes, you will need to move that database over as well.

How do I program against a local database while I develop in ASP.NET MVC?

At my work I found out that we belong to some program with Microsoft and get access to various products because of it.
I've downloaded Microsoft Visual Studio 2010.
I'm not a professional programmer but I've dabbled before and I wanted to check out ASP.NET MVC. I know that I want to use some flavor of SQL Server and that I want to create a hobby website as a project (which may get deployed at some point in the future).
How do I create the schema for, and code against a local database that resides on my machine and then at a later point, use an external, actual SQL Server?
Does VS2010 make programming against a local SQL Server database pretty easy?
Developing against a local database is simple.
Download SQL Server Express (or SQL Server from MSDN, since it sonds like you have access).
Use your Web.config file to store your database Connection String. You can utilize it in your application using:
using(SqlConnection conn =
new SqlConnection(ConfigurationManager.
ConnectionStrings["MyConnectionString"].ConnectionString))
{
}
All you have to do is change the connection string in your application to point your application to the Production server:
<connectionStrings>
<add name="MyConnectionString"
connectionString="Data Source=localhost;
Initial Catalog=myDataBase;
User Id=myUsername;
Password=myPassword;" />
</connectionStrings>
Becomes
<connectionStrings>
<add name="MyConnectionString"
connectionString="Data Source=ProductionServer.MyDomain.com;
Initial Catalog=myDataBase;
User Id=myUsername;
Password=myPassword;" />
</connectionStrings>
Check out this tutorial:
Create a Movie Database Application in 15 Minutes with ASP.NET MVC
In "Creating the Database" part it shows you a complete step by step guide to create a local database using Microsoft SQL Server Express that comes bundled with Visual Studio.
Check out this MSDN Section, "Using SQL Server Express with ASP.NET:" http://msdn.microsoft.com/en-us/library/ms247257.aspx. There's a series of articles here that should help you get started with your MVC site and SQL Express.
There are various tutorial that will show you how to connect to a local SQL Server Express and use Visual Studio's Server Explorer to create database objects, or design the database schema in the LINQ modeler and use the LINQ Datacontext deployment methods. this approach threats the MDF file of the database as a binary file of the project. Previous answers already pointed out the most popular ones.
What all these tutorials will fail to mention is that this method works only to deploy v1 of your product, and fails miserable when you want to deploy the next version. None of these methods provide a way to deploy a database schema upgrade to a production runing site.
For a hobyyist developer this approach will work, but a professional shop will have to use a much different approach. SO itself is full of questions from developers burned by the naive approach trumpeted in these tutorials (questions ranging from 'how do I check in my MDf in SVN?' to 'I have made modification to the MDF, how do I dpeloy them to my hosting?'). One alternative is to use a Visual Studio Database Project, define the schema in the database project that produces a .dbschema file and use the vsdbcmd tool schema diff deployment capabilities. Another alternative is to take full control and deploy all schema objects via upgrade T-SQL scripts: for each schema change, an upgrade script is created that deploys the change from vN to vN+1, and marks the database schema as being at VN+1. This later approach is best fit for multiple deployments, when each location may be at a differne tversion and each release has to be able to upgrade the schema from any verison on disk to the desired version, by running succesively all the upgrade scripts from the current on-disk version to the desired version. This, in fact, is the approach used by SQL Server itself to upgrade the resource database.

ASP.NET MVC Tutorials using SQLServer?

How can I use SQLServer (instead of SQL Express) as my database?
I'm trying to go thru the ContactManager tutorial, but I can't seem to get it to use SQLServer - when I pick SQLServer from the "Add New Item" dialog, I get an error telling me that SQL Express isn't installed.
I know I must be missing something basic...
Most tutorials on the ASP.NET site are written in such a way, that you don't have to buy any software to do them. They use Visual Studio Express and SQL Express in their examples.
However, You can still follow along with the tutorial. Just make a few adjustments. Go to the Server Explorer to create a Connection to your SQL Server, and create the database and tables.
Then when it comes to the step of creating the EntityDataModel, create a new connection to the database you just created.
Only SQL Express can attach your database at runtime. If you have a non express version of SQL Server you will need to create the SQL Server using SSMS. If you want the file to physically live in app_data then when asked where to put the database file and the ldf indicate the app_data folder. Once you have created it, it is easy enough to simply add it as an exsisting item, although it can't be checked into source safe without creating obvious issues. I hope this helps.
If you're using a full-fledged instance of SQL Server, you don't need to use the "Add New Item" dialog at all. Rather, connect to your SQL Server instance (via Visual Studio or SQL Server Management Studio), and create the new database there.

Resources