I recently finished my asp website, bought the domain and azure hosting. Unfortunately, when I try to do anything that accesses the database I just get stuck on a loading screen. I just used the default asp razor mvc 5 project I think for the database along with a couple of custom tables.
So here is how I would do it since you have an existing database. I would follow azures website, and set up a SQL database. I would then script out the database on you local machine, and log into your azure database using SQL Server Express. Execute the script you generated from localDB. Then all of your data will be good to go. You will then need to take the connection string from azure, and put it in your applications config file. After modifying the connection string in your application you should redeploy, and verify everything is working the way you want. You will be able to verify your data is there in SQL Server Express.
Here is a link that may be of quite a bit of assistance to you. It includes step by step instructions as well as screen shots.
Another option is using this tool. I have never used it, but I know a few people who have had great success with it.
Related
I have thousand of SQL Server databases (one for each client). When we decide to push on production, we have most of the time changes in databases, the web API and the web application.
The problem is the time it takes to deploy everything, especially the databases. We are using Code First migration and MVC .NET and SQL Server, all with the latest version. It is a SaaS. And the code first migration process is able to update the database one-by-one.
The API and the web application are deployed very quickly within a few seconds. However, the databases are all updated within about 30 minutes. During that time some users got errors and cannot use the software because the API tries to target non-updated database. And worse, if during the databases update, something fails and stop, the non-updated users are stuck until we fix the issue and update the rest of the databases.
Any idea how to solve this problem and make clients happy?
PS: The web application doesn't access to the database, but only the API.
This question is somewhat opinion-based. The maintenance window approach is the easiest. If you want to do live-updating, another way would be:
Keep a version number in the database
Allow running multiple versions of the Web API side-by-side
Choose which version of the API to use by looking at the version in the database
Determine if the Web API's public interface is stable. If it is not, also find a way to allow running multiple web sites side-by-side and choose which one based on the version in the database
The most maintainable way to accomplish this would probably be to have at least 3 servers:
One backend server which hosts the old version
One backend server which hosts the new version
The frontend server which routes users to the proper backend server based on the current version.
The routing could take place only at login, or you could do something more fancy such as redirecting the logged-in user when an upgrade is detected. Obviously none of this deals with what happens to one particular client during the actual upgrade of that client's database. You'll still need to address that separately.
In general I need to know amount of visits on my website and access that data via API to have it everywhere.
For this I am trying to share EF database with 2 projects. One is simple Azure ASP.NET website with one controller which collects statistics of site visits. Second project is Azure mobile service that connects to the same database as website and provides access to that statistic via GET requests.
Locally I am getting such error:
Cannot attach file '...App_Data\aspnet-TargetrWebsite-20151001100420.mdf' as database 'aspnet-TargetrWebsite-20151001100420' because this database name is already attached with file '...\tagetr_statisticService\App_Data
So the problem that I have 2 web.config files with connection strings that points for 2 different files with the same database name.
How to get this work with one file on localhost and keep it worked on production as well?
Actually my target is know visits of page from everywhere. It is not required to use separated service for this. Just adding new authenticated controller which binds to Visits table on the same website solves the problem. Service removed then.
This could probably be done via Powershell script which sits on any machine.
Here's a good start where you can get back a list of IP addresses which are stored in an xml. You can then pull the xml into API quite easily I would believe. Also it should be quite easy to convert IP to url or location etc.
https://www.petri.com/powershell-problem-solver - Thanks to Jeff
Remember to watch your permissions!
Ok. I made website (in VS 2012 ASP.NET MVC 4) and I have database on my local sql server that website uses.
Now, what do I have to do to put it online.
Is there any good tutorial that shows how to do this from scratch (there must be but I can't seem to find any).
So I want to know things like:
- what are the best hosting sites
- do they offer space for my database and how can I connect to this database from sql server or do I have to buy space for my database somewhere else...
-where to put files I get from publishing my website from VS
-etc..
Scott Hanselman has an article here to Bin deploy your MVC project to your server via FTP.
Follow next steps:
you would buy a space on Windows server via a host. Once you do this, you will get the FTP server address, username & password that you would use when Bin deploying.
Buy a domain via services like godaddy.
Link your domain to your server by changing the name server address through godaddy's control panel.
That's it. This is in short assuming you understand the basics of hosting, domain etc.
I would recommend you to check out Windows Azure. That is one of the best and easiest hosting services I have tried at least. For instance, when you create a website, you can just download the piblish profile and right click at the project in VS and choose publish. Select the publish profile that you downloaded and most of the time you are done.
Check out Troy Hunt's: worldsgreatestazuredemo and Azure Friday to get a feeling for what Windows Azure is.
I've got some silly questions, but I'm quite new in mvc and haven't found any appropriate answers,so:
1: In asp .net mvc4 internet application, as you create a new project VS. creates registration by default. If u register a new account, does mvc store this in a database? (I read that it stores, and can be found in appdata, but it's empty for me, and in server explorer there is no connetion, but I can log in and out after registration, it works perfectly.) Do I have to set a new sql server for VS or it handles this by itself? So how does this exactly work?
2: My goal is to modify the registration form to store id,name, fullname, email, registration date as you register. How can i achieve this by "extending" the default registration?
It does use a db. Check the connection string in web.config. VS 2010 uses SQL Express I believe and VS2012 uses localdb. SQL is installed with VS. The db file is usually installed in the app data folder but it does get generated until the first user is created. I suggest you get Microsoft SQL Management Studio if you want to look inside the DB, or use sever explorer from within VS.
This post perfectly answers to both of your questions
I am having issues deploying my app to godaddy hosting using EF code first. I dont want my app to create the database since the database already exists.
So I read some posts on here and placed this in the constructure:
Database.SetInitializer<myContext>(null);
Now I get a permission error writing to the temp file.
Anyone had a successful experience deploying this to godaddy shared hosting?
When the project used Model first and edmx files it was deployed fine.
I was able to get this to work right after posting this..
All I had to do was move:
Database.SetInitializer<myContext>(null);
to the global.asax Application_Start
Can you post what's the server error you are receiving.
setting db initializer to null should work fine. I have tried that. If you post the exception, we can probably find out why exactly that happening
You should use a generated database from the development and remove the database initializer from your code. From my experience, I always got a problem if I didn't remove the database initializer.
I've faced kind of problem before. I am using a different hosting site though. I deployed my MVC 3 Code First app back then. When I deployed the app, I didn't remove the database initializer, so the app drop the database and try to create it again. But when it create the database, it got a permission error. The problem is, the database is actually dropped in the server but in the hosting site cpanel, it is still exist. I send a ticket to the support, and problem solved.