Change servers (Dev, UAT, Prod) for Entity Framework - asp.net-mvc

My application is developed in ASP.NET MVC with Entity Framework (using a database-first approach). Currently, this entity is pointing to the dev database server. I want to change it to an UAT server for testing and finally production server for deployment.
My question is, is it achievable only by creating a different .edmx file for each of the servers always and rebuild it? Or is there an easy way to change it other than creating a new connection (.edmx file) every time?
Thanks

Related

Creating Database Project from Database in Azure

Here are the steps I took:
In Visual Studio, I created an ASP.NET MVC application with authentication
I specified that the database is an Azure SQL Database living in the cloud
So at this point I have a single project in my solution, the web application project for ASP.NET. And I have this database created in Azure with my membership database objects.
Now what I want to do is create a database project in this same solution for more detailed and in depth database development.
I created a database project, and I can easily set to deploy to Azure but I would be "overwriting" the Azure database that was created initially.
How can I "refresh" the database project I just created to reflect the existing database in Azure at this point so I'm not overwriting?
Basically I'm looking to "sync" up the existing Azure SQL Database with the new database project I just created in the solution.
Any way to do this?
Thanks in advance!
Basically what you want is the Schema Compare feature from SSDT (Sql Server data tools)
https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx

Run Umbraco 7 without database

I understand that Umbraco caches all database content in an XML file on the web server. Would it be possible to run an Umbraco instance with just that file, and no database?
The idea would be to do all editing on an instance with a database, but have UAT and Live as read only environments without a database. Deploying dev to UAT or Live would mean copying all updated files and the XML file to the database-less UAT or Live instances.
This is possible, please see Decoupling Umbraco from your front-end website.

entity framework db first

I have built my MVC 5 project based on entity framework Database First approach by following video tutorials. But what I have obtained is the model. There is nothing in the app_data folder. I want to obtain the .mdf file as well so that I can deploy the database to the azure.
Note: I'm using the server explorer database in VS2013.
I dont think you will be getting any .mdf files on app_data folder.
To deploy your database to Azure:
Right click your database on SQL server, then Tasks->Generate Scripts. On scripting options, select sql azure server
Login to your azure account and create a SQL server and run generated script from the portal by clicking the link below:
while creating your EF connection, use the connection string for your Azure Database like:
At the end you should be ready to use your ORM.

deploy asp.net solution to multiple hosting systems

I am working on an asp.net solution and using my remote testing environment with godaddy.
The application is ready for deployment so i have two questions:
1- since the database will be different , i am thinking about using a different Web.config , but not sure how does it work and how to implement that so i can choose easily which web config depending on the poriject/solution
2- the solution i am working on could be personalized and deployed to multiple clients , so each client version will be different (Like the logo and other stuff not the design and functionality), do i need to create separate solution for each client or should i create a separate website project instead?
what's best practices in this case
Use configurations and associated config transforms. By default, your project gets a Debug and Release configuration, but you can add additional configurations. Then, for each configuration, you can have a separate Web.config transform, Web.Server1.config, Web.Server2.config, Web.Client1.config, Web.Client2.config, etc. When publishing, you choose which configuration you want to publish with, and that associated transform will be run against the Web.config file to change out connection strings, app settings, whatever.
For more information see: How to: Transform Web.config When Deploying a Web Application Project | MSDN

Deploying ASP.NET MVC Database to Production

How do you deploy a database when you deploy an ASP.NET MVC application to production?
I've created a standard ASP.NET MVC3 application that uses SQL Server 2008 (albeit Express) for my app. I'm using the standard forms authentication stuff that comes with ASP.NET MVC apps.
If I have to re-create my schema, for all my classes (i.e. the non aspnet_* tables), then I have SQL scripts I can run against the production DB; but what about the aspnet_* tables?
Or should I simply upload an ASP.NET MVC empty DB (~10MB) and then run my scripts against it to create my tables? Surely, there must be a better way.
(Once this is solved, I plan to use SQL scripts or DB migrations to handle changes; it's only the question of generating the initial database in production without uploading the ~10MB .MDF that I can't get around, because of the aspnet_* tables.)
You can use aspnet_regsql.exe, located under C:\Windows\Microsoft.NET\Framework[your framework] to generate the schema in your db.
Run:
aspnet_regsql.exe /?
and you will see all of the command-line options this executable takes. -A lets you specify what features (i.e., tables) will get created. If you do not use roles, for example, you may just use -A mp.
You can choose to have it modify your database directly, or instead create a script that you can run. Some details here: http://weblogs.asp.net/lhunt/archive/2005/09/26/425966.aspx
You could run aspnet_regsql utility on your (empty) production database to generate the aspnet_* tables. Check out the MSDN article on the utility.
You can also deploy the db using Visual Studio.
In VS, open the database explorer window
Add a connection to your local db
Right-click on the database and choose 'Publish to Provider'
The db publishing wizard will open
The wizard lets you select which db objects you want to deploy (tables, stored procedures, etc.)
Select the 'Script to file' option, which will create a script that you can run on your prod db
Open SQL Server Management Studio
Connect to your prod db
Open the script file you created with the wizard and execute the script

Resources