I've created a small website and now want to deploy it to web hosting www.citynetwork.se. I've successfully deployed the MVC4 code developed using .Net 4.0 framework. The connection string I'm using currently for localhost is;
<add name="EventtavlanContext" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=Eventtavlan1;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Eventtavlan1" />
It works perfect at localhost but how should I deploy the database to the web hosting?
As my web hosting provides support for MySQL and MS SQL so should I
create a new database on web hosting and create/deploy the schema
only? How would I do that?
Should I include the database from App_Data folder while
publishing from VS 2012 to the web hosting and change the connection
string only? What would be the new connection string then?
Or is there any other way of deploying the database? Can somebody guide me
with the easiest way?
Thank you.
Yes, create a new MS SQL database at the hosting provider. If you want to deploy the schema you can do that easily from Visual Studio using the dbDacFx provider. See http://msdn.microsoft.com/en-us/library/dd394698.aspx#dbdacfx .
No, don't include the .mdf in App_Data. You can't use a LocalDB database when running in IIS. When you create the database at the hosting provider they should provide the connection string.
Easiest way if you only want to deploy schema is dbDacFx provider as I mention in #1. That page I link to also mentions other options. If you're using Code First, Migrations is a good way to deploy. See this tutorial: http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/introduction
Related
I have an API published to Azure App Services, using ef core, connect to Azure SQL database. below are the steps and the problem:
The Azure SQL database is up and running OK, I setup two firewall rules, one for my local dev ip, one for Azure App. I can connect to Azure SQL from local without any issue, and I have done the migrations.
I copied the connection string from Azure SQL and put in the appsettings.json, running the API from my local and connect to Azure SQL without any issue.
I published my API to Azure App services without any issues, I can see my app running OK since it has static file.
Then I went to Azure App Services => Settings/Configuration => Connection strings, create one new connect string with the same key/value as I used in the appsettings.json, based on the document from Microsoft: https://learn.microsoft.com/en-us/azure/app-service/containers/configure-language-dotnetcore#access-environment-variables
But the problem is after I done these, my API still not working, the api call to SQL return error 500.
Anything I missed or did wrong?
Thanks!
Thanks for the comments CSharpRocks, I did by adding the client ip, but I figured that's not the right way, so resolved by set the "Allow Azure services and resources to access this server" to True, that works.
For Others looking for the answer I had followed the steps above and it still did not work for me. But when I went to Visual Studios --> Publish --> Service Dependency's --> Add Azure SQL Database That fixed it for me.
So i have a localdb set up for my project in Visual Studio but when I publish it to my Azure web app, I get "
An unhandled exception occurred while processing the request. Win32Exception: The system canot find the file specified TryGetConnection"
I tried adding a "DefaultConnection" Connection String with the database/server as the value in the Web App settings but that didn't do anything
LocalDb doesn't exist for Azure. LocalDb is a feature of SQL Server Express, there is no equivalency of that on the service (machine) you are deploying your App Service website on.
There are plenty of options instead of LocalDb when you go to Azure. The easiest (and recommended) is to use an Azure SQL database and replace your connectionstring with one that points to that instead when you publish your website.
Some other options are discussed here Using a LocalDb MDF file on Azure
I am using VS 2012, connecting to SQL Server 2008 host using windows credentials. I can connect fine from Management Studio, but when I run a web application (IIS 7.5 windows 7 ASP.NET 4.0 integrated) and my application tries to connect, I get this:
Login failed for user 'MyDomain\MyMachineName$'.
For some reason IIS App pool using Network Identity is not using MyUserName but my machine name instead. My connection string is:
<connectionStrings>
<clear />
<add name="Assignment"
connectionString="Data Source=a.b.c.d;Initial Catalog=My_Db;Trusted_Connection=true;Max Pool Size=200;Pooling=True;" />
</connectionStrings>
I should mention this is a new (to me) computer. I looked in credential manager and there is nothing there. Any ideas why IIS and my web app using the wrong thing?
IIS is actually doing exactly what it was designed to do when you run your app pool under the Network Service identity.
Using the Network Service account in a domain environment has a great
benefit. Worker process running as Network Service access the network
as the machine account. Machine accounts are generated when a machine
is joined to a domain. They look like this:
<domainname>\<machinename>$,
For example: mydomain\machine1$
The nice thing about this is that network resources
like file shares or SQL Server databases can be ACLed to allow this
machine account access.
The quote above is from the following documentation...
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
Hopefully this answers the question of why it isn't working the way you expect.
As far as how to make it work the way you want, I think this article should answer that question, and if not, some basic google searching should come up with quite a bit of information on how to properly configure your environment for what you're trying to do.
https://gilesey.wordpress.com/2013/05/11/allowing-iis-7-5-applications-to-communicate-to-sql-server-via-windows-authentication/
I have created an ASP.NET MVC 3 application locally and now I'm wanting to publish it to windows azure server (which is all set up fine within my account) so that it is accessible by anyone.
However I'm having issues as the database used in the application and the connection strings in web.config are localdb.
How do I go about changing localdb to SQL database so that I can host the website live properly?
Do I just need to change the connection strings or is there further configuration required on the server or in the application?
Just change the connection string from localdb to SQL Server.
I am newer to Visual Studio 2012 and MVC4, and have a development project of a website using C# and MVC4 and SQL server 2012.
The Publish using web deploy works for the website portion of the project, but it does not automatically update the database portion (schema). If I right click the database portion of the project in VS2012 and click Publish, then the database schema is updated properly. I am only interested in schema updates. What could be wrong?
I programmed my development system to use Web Deploy 3.0. Here is a summary of my configuration:
Computer running win8 x64
SQL Express 2012 as my database server, running as the default instance (i.e. at localhost, NOT as .\SQLEXPRESS)
IIS Express 8 as my webserver, using the "Default Web Site" site (localhost)
Visual Studio 2012 Pro using MVC4 and C#
Web Deploy 3.0
The latest dates are all applied to the software
I programmed an SQL server user WDeployAdmin for managing the database updates and gave it full permissions over the database being used for the website. I also tried using Integrated Security (my administrator login) but that does not help.
I can correctly update the Default Web Site (views and controllers etc) using the Publish feature in VS2012 which uses Web Deploy 3.0.
When I use the Test Connection feature of the publishing setup options, it correctly connects to the database, and that certainly works fine when I do a separate Publish DB operation (right-click DB project, click Publish, and then pick my profile) for that part of my project.
So why doesn't the standard website Publish feature include the database schema updates? The standard website Publish always shows an empty change to database when the schema changes (e.g. a table or a stored procedure).
I have read through much MS docs but nothing is apparent to me.
Any help is appreciated,
Bruce