During installation of the latest driver for my AMD Radeon graphics card my desktop blacked out and wouldn’t go anywhere. I did a hard shutdown and on startup I was presented with the Windows log and spinning ‘dots’ that kept going and going. It would not pass this stage:
Doing some Googling I came across various suggestions as to how to fix this (there is a variety of things that can cause it, from Windows 10 updates to other software update). Generally speaking it was to shut off your computer three times in a row while on this screen or hold the shift key while restarting. None of those worked for me. I had to do a true hard reset, cutting the power completely, by pulling power cord once presented with the screen above. You need to repeat this step until you see the following screen, ‘Preparing Automatic Repair’:
A blue window will then pop up, click Advanced options when the automatic repair screen comes up:
Then on the next screen click ‘Troubleshoot’:
The click ‘Advanced options’ again:
If you know what caused the issues, as I did since this started happening immediately after my attempt to update my graphics drivers, click Startup Settings:
Then on the next screen click Restart. Once it has restarted you’ll see a list of startup options and in order to get into safe mode you will click 4 to enable safe mode and you’ll see a simple version of Windows that’ll allow you to uninstall / undo what you did to cause your problem in the first place.
Even though we are using a Microsoft framework (MVC) and ADO.NET Entity Framework (EF) we may not want to connect to a Microsoft Database. In my case I am going to connect to a MySQL database which means I have to configure MySQL for use in my project.
I had to download the latest version of MySQL for Visual Studio installer and once downloaded run the installer and follow the on-screen prompts to install. I went with the Typical install option.
I then downloaded the latest MySQL connector and ran the installer also using the Typical install option.
Once this is done you can open your project in Visual Studio and right click on the solution in the solution explorer to Manage NuGet Packages… as in Figure 1 below.
You then go to the Online section and search for MySQL. You then want to install the MySQL.Data.Entities package, highlighted in Figure 2 below, by clicking install which will then install the NuGet package and it’s dependencies (Figure 3) and once it’s done a green check mark will show that the package installed correctly (Figure 4).
After you have MySQL configured you need to add the MySQL provider to your Web.config by replacing the Entity Framework tag with the following:
Then you save the Web.config file and add an ADO.NET Entity Model by adding a new item (Figure 5) to your solution. The new item is an ADO.NET Entity Model which provides the connection to your database (Figure 6) by selecting Visual C# from the left menu followed by ADO.NET Entity Data Model, giving it a name (in my case TrackerDB) and clicking Add.
In the window that appears select the option EF Designer from Database and click Next (Figure 7). In the window that appears, Figure 8, click the New Connection button to create a connection to your database and select MySQL Database from the list of options, Figure 9. Make sure to deselect the option to always use this selection and click Continue.
The Connections Properties menu will open where you will need to provide the details for the database server your application is going to connect to, as in Figure 10. In my case I entered the server name as an ip address since no DNS friendly name exists along with the username and password required to connect to the database server. You can click the Test Connection button to ensure your information is correct; however, in my case I also noticed that you can attempt to select the database you want to. If your credentials are incorrect an error message will appear, otherwise a list of databases the username/password combination has access to will appear. If the connection succeeds click OK, returning you to the previous screen.
As an aside I find it best to create a username/password combination that is unique to each database, rather than one to rule them all, so that if the credentials get compromised only access to a particular database will be granted. If you have finer grained control over database usernames it is best to only grant a user the rights to do the minimal tasks required.
After clicking OK I received an error message (Figure 11) about the XML declaration. I clicked OK which brings you back to a screen like Figure 8 above, however, information will be populated under the connection string. I determined this was caused by me having extra lines, which I had commented out as part of my experimentation, at the top of my Web.Config file. After deleting these lines making the <?xml …> tag the first line in the file I was able to proceed (canceled, deleted the connection and started from the beginning) without error which brought me back to the screen as seen in Figure 12. I stuck with the default name provided for the connection string in my Web.Config file and choose yes for storing my password since the account only has the writes required. I may decide to change this later and how you wish to handle this is up to you. You then want to click the Next button.
Update (Aug 22, 2014): You may want to provide a better name for your connection settings in your Web.Config file as that acts as your context. That is if your database is called tracker then db_nameEntities could be TrackerContext.
On the next screen you will see “Retrieving database information, please wait..” followed by the various elements you can select to be included in your model. In my case I selected only Tables as I currently have no Views or Stored Procedures and Functions for my database, as seen in Figure 13. I left the default to pluralize or singularize generated object names as well as to include foreign keys since I want my model to include the foreign keys. Click Finish to complete the Entity Data Model Wizard.
Update (Aug 22, 2014): You may want to provide a more friendly model name for your database model, again if database is called Tracker you could use TrackerModel.
You will receive the message “Running this text template can potentially harm your computer. Do not run if you obtained it from untrusted source.. ”, as a reminder that you are about to execute someone else’s code which you should only do if you trust the source of that code. I am confident in this case that I can run this template so I click OK, which I had to do a couple of times. If you want you can disable these warnings by going to Tools > Options… > Text Templating and setting the Show Security Message to False.
Under Data Connections in the Solution Explorer I able to see the database I added. At first it showed as having a red ‘X’ next to the database icon, but once I expanded the connection to see the contents, Figure 15, the icon refreshed and the database contents were displayed which signifies that I now have a data connection established to my database for use with my application.
Finally now that everything is configured you are able to see an ERD diagram of you database open up as well as the database schema in the Solution Explorer that you can navigate, shown in Figure 16.
The connection string added to my Web.Config file under the <connectionStrings> tag looks similar to below, but with the actual values for server, user id, and database. The reason for the connection string (with the space) and the " sections is because it is escaping the connection string generated for the database I am connecting to and putting it into the web configuration file under the connectionString attribute. I will have to see if this works as generated by the wizard or if I will have to modify its results.
Note: You may not run into this, however, there were times throughout when Visual Studio would go into a non-responsive state (sometimes flashing in and out of them) throughout the process. I found that I just had to be patient and give the application time to complete the necessary tasks.
The web hosting provider I am using is GoDaddy and I chose Windows hosting since some of my ideas include developing web applications using Microsoft technologies. The following explains how I set up my first web project I am in the process of developing, which was my tracker application.
The first step is to get the web deploy publishing settings for the location you wish to host your web project. In my case I want to host it on a subdomain (which I have already created), but the steps are the same if it is your root domain. You navigate to the subdomain section of where you would like to host your app in GoDaddy’s ‘Websites & Domains’ section. You then click the ‘Web Deploy Publishing Settings’ link to start the download of your settings file (seen in Figure 1 below).
The downloaded file will contain a .publishsettings extension with the contents of the file similar to:
<?xmlversion="1.0"?><publishData><publishProfileprofileName="tracker.dwcryan.com - Web Deploy"publishMethod="MSDeploy"publishUrl="tracker.dwcryan.com"msdeploySite="tracker.dwcryan.com"userName="dwcryan"destinationAppUrl="http://tracker.dwcryan.com"controlPanelLink="https://p3nwvpweb100.shr.prod.phx3.secureserver.net:8443"/></publishData>
Once you have the settings file you can configure your actual project. With your web project opened in Visual Studio you right click on the project in the Solution Explorer and select Publish.. (or something similar depending on project type) as in Figure 2.
This will present you with the window in Figure 3, where you will select the Import option by left clicking. In the displayed dialog ‘Import Publish Settings’, also displayed in Figure 3, you will browse to your publish settings file, select it, and then click Open; thus, displaying the path to your file in the ‘Import Publish Settings’ dialog as in Figure 4, and then click OK.
Once the settings have loaded enter the password for your account and click Test Connection. If everything is OK you will see a check mark next to the test connection button as in Figure 5.
Clicking Next will then take you to the ‘Settings’ tab. I did not change anything here as I did not see the need for any file publishing options and I do not want the publish to modify my database. I may need to update my publish settings and insert a connection string for my database once I have that configured within my application and will update this post with any such changes. Clicking Next again brings me to the ‘Preview’ tab as in Figure 6.
Clicking ‘Start Preview’ in the middle of the screenshot above (Figure 6) will provide a list of the files being uploaded and the action being performed (i.e. update for files being modified and add for new files being pushed to the destination) as in Figure 7.
Lastly you click Publish to finish off the process which will publish your application to its destination. The output of the file will look similar to that of Figure 8 (I cropped out the middle section as to highlight the start and end sections as well as displaying some of the adds and updates. The web application (at the URL provided) will then open up in your default web browser.
If their are issues with the settings in your application when running on the remote server an error page will be displayed with some information as to what you have to do. At this point it becomes a matter of experimenting. In my case I got a security exception stating “The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file”.
I was able to solve this by adding the following line to my web.config file between the system.web tags and publishing again:
<trust level="Full" />
Through further investigative work I determined a second option is changing the configuration on your hosting provider, if they allow it. In my case that involved selecting the option ASP.NET Settings in the same view as Figure 1 above, which in my case was at the bottom of the 3rd column (from the left). Once in there you set the CAS trust level to Full, Figure 8 below, and while here make sure that the Default webpage language is correct for your application.
That appears to be it for now and will have to see what happens once my web application contains a database and actions are being taken if any further modifications to the publishing settings need to be added or modified.