Upload MVC4 site to server [duplicate] - database

This question already has answers here:
Uploading MVC site to server
(3 answers)
Closed 8 years ago.
I've developed website based on .NET MVC4.
I used simple membership .NET built in forms authentication.
I saw that the application uses some kind of MS database, but I don't really know what kind.
I want to upload my site to server and publish it.
Do I need to install some kind of database on the server? or I'll just need to upload the application and it will create the database on the server automatically?
Thanks.

The database created by default when using the MVC 4 Internet template is a SQL Server Express LocalDB, which is really intended for development and testing and not for deployment. Although I think some people do use it in production. If the correct components are on the server you are deploying to it will automatically create this database. If you look at the web.config generated by the template it looks something like this.
<add name="SimpleSecurityConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SeedSimple-20130125152904;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SeedSimple-20130125152904.mdf" providerName="System.Data.SqlClient" />
The name for the configuration string to use is defined in the WebSecurity.InitializeDatabaseConnection method as the first parameter. You will notice that the data source starts out with "(LocalDb)" which tells the runtime to use a LocalDB instance. I would recommend installing something like SQL Server Express or a full blown SQL Server instance on the server and changing the connection string to point to it instead for production.

You should explain more about state of your application database. At least you should let us see your working connection string(s).
If you have all your data in a single database - your own tables and the membership made tables - and your database is attached to a local database instance, you just need to generate a script from your current database and run that script on the database server of your web host.
Many scenarios exist according to the type of your application database (source) and the type of your web hosting database server (destination)...

Related

How can I connect my SQL Server database that is placed on another server using API or Web Service in MVC to website that is on a different server

I uploaded my website to GoDaddy web hosting and the database is placed on another server.
I want to create an API - either REST or SOAP - to connect my web site with my SQL Server database.
I need help - how can I create an API in ASP.NET MVC 5 so that I can connect my database with my web site? Kindly provide me with a link or code so that I can solve my issue.
I have never worked on API before - any help will be much appreciated.
ASP.NET MVC is now old school. Try ASP.NET Core.
You need to design and develop an N-Layered application: Data, Service and UI.
It doesn't matter where the database server is sitting, as long as your WebAPI can connect to it.
I suggest you build a restful web api with asp.net core :
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&tabs=visual-studio
Put your db connection string in the app settings file.
Although you use other database server, it doesn't matter. You just need to make sure you check your connection string and point it to your database server. For publishing method, it is same, you can use FTP or Visual Studio
Please open your project with Visual Studio tool
On the Solution Explorer windows (which is normally located on the top right hand corner of the VS tool), right click your project and select Publish
Please kindly publish it to a local folder, such as C:\Project
Please just upload whatever files/folders you see on C:\Project to your server via FTP
If you have any problems, you can contact your support team
You can get the Reference from
Sample_WebAPI_Project ,
instead of Using List created you can create Database Connection and get data from Database

WPF Application with SQL Server Express database deployment in production environment

I have a WPF application where I use Entity Framework for interacting with the database that is on SQL Server Express on my machine. I'm reasoning on small projects where data will not be huge and then I don't want to install SQL Server Express on client's machine for two reasons:
installation takes a long time
these projects must be executable on computers with low hardware specs (installation of SQL Server takes too much time)
I tried installing LocalDB on client machine, created default instance and started
The problems are two:
how to reconfigure app.config file making Entity Framework connecting to database? (in development environment connection string is SQL Server style)
where to put database files? (user's profile root?)
Am I following the correct way? I know only two way to do this, installing SQL Server Express or using LocalDB the may be a third way?
You can set up your app.config file as follows (just replace "C:\Database.mdf" with the full path to your database):
<connectionStrings>
<add name="NameOfConnectionString" connectionString="data source=(LocalDB)\v11.0;attachdbfilename=C:\Database.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings>
But with this you will end up having always the same static connection string.
Perhaps you want to store you database rather in some user folder.
This will get a sub folder of the users documents folder at runtime:
string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyAppsFolder");
If you want to deploy the local db to the users machine, you might want to create a installer project for this. See here
The alternative would be to install some version of SQL-Server on the client machine.
If it is possible that one the client site you will have more than one concurrent user you will have no other choice.
Difference between local db and SQL-Server express
If you need more information on the usage scenarios of local db and SQL-Server express, check out this question and answers.
This MSDN Site has also a bunch of information on LocalDB.

How to host mvc5 project with Database on Godaddy server

I have 3 projects (MVC5 Web, Database and DB First EF) in one solution. I can host properly MVC5 simple app (not including database) in Godaddy server. I'm able to create DB in Godaddy server too (i.e. by creating scripts in local SQL Server MS in my pc and pasing in the Godaddy SQL Server. Its working fine.) and got Connection string. Now my question is,
1- Should I host my "DB First EF" ? If yes then how ?
2- Suppose I want to change my DB, how to modify my edmx file in server? (Like we do in Visual Studio When ever we modify any DB object, We can change our edmx manually.)
Any suggestion would be appreciate. Thanks in advance.

Publishing SQL Server database in Access to Sharepoint

In my project I need to publish an Access database into Sharepoint. I need to add a web form into it. Is it possible to add a WebForm that can be shown in the Sharepoint site, using ODBC(Database from SQL server on local machine)?
I can connect to that database and edit records in it. But I can't make a form with that web icon on it. Is that even possible to publish something from Access to Sharepoint using local SQL server and make a form to show data from it?
I found something like that:
I totally missed the fact that this was a web app. Access web apps
work with SharePoint, no other data source. That's true for Access
2010. But in Access 2013, there is a hybrid solution possible: Access Client + Access Web + SQL Server. It's still very new and not
common yet, and unfortunately there isn't a migration path from Access
2010 web forms to Access 2013 web forms. You have to build the web app
from scratch. But it's a better platform than Access 2010 offered.
that means i should use access 2013 ?
I am no expert and can't test my ideas, but I read that if you publish an Access db with Access tables to SP, Access tables will be converted to a SQL Server table by SP. Perhaps you could then delete or rename the SP created table on SP's SQL Server and create a view with the same name which points to you table on the other server ?
Have a look at the SP site: https://sharepoint.stackexchange.com/q/104005

Upload DBFile.mdf in App_Data to Azure

I have my ASP.NET MVC 3 project with a local database stored in /App_Data directory. This db is SQLExpress file (*-mdf).
I have my connection string working perfectly in my development CPU, the Connection String is:
data source=.\SQLEXPRESS;initial catalog=CFCBBSecurity;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MYFILE.mdf;User instance=true" providerName="System.Data.SqlClient"
When I upload it to Azure, using VS 2010, all files are in the server, but the application cannot access the Database.
What should I do, change or update?
Thanks in advance.
The problem is that you're referencing a local SQL instance (.\SQLEXPRESS, the 'dot' stands for localhost). I'm assuming you are running SQL Server 2005/2008/2012 Express on your machine and that's why this works locally.
But when you deploy your application to Windows Azure, there's no SQL Server installed on that Web Role/Worker Role/Web Site (this would be a bad idea anyways because Web/Worker Roles are not persistent!).
What you'll need to do is sign up for a 'cloud database' like SQL Azure and use that. Or you could host it yourself in a Windows Azure Virtual Machine (which is IaaS, but this involves more work).
If you're building an MVC 3 application I would suggest you simply start with SQL Azure. Here is a tutorial: Running ASP.NET MVC 3 Applications on Azure (note that this tutorial contains screenshots of the old portal).

Resources