EF Database First with ASP.NET MVC 5 and Oracle Database 12c

NuGet Package Manager

There is a great article called “EF Database First with ASP.NET MVC” by Tom FitzMacken that is part of Microsoft’s ASP.NET MVC tutorial.

I wanted to create a website using the steps outlined here, except instead of using a SQL Server database (as was presented in the article), I wanted to use an Oracle 12c database. Unfortunately, Oracle was not an option in the list of Data Sources as in the image below:

no Oracle option available
Oracle DB was not an option.

I had the basic Oracle setup on my development server, however, I found that I did not have Oracle Developer Tools for Visual Studio. I installed the 32-bit version and rebooted the server; I have not tested the 64-bit version for this particular project. Also, I changed the .NET Framework from 4.5 to 4.6. (From what I have read, 4.52 is the minimum that will work with the EF 6 / Oracle setup.) Lastly, I installed several NuGet packages:

  1. Official Oracle ODP.NET, Managed Driver
  2. Official Oracle ODP.NET, Managed Entity Framework Driver
  3. Oracle Data Provider for .NET (ODP.NET) Managed Driver
  4. Oracle Rdb Entity Framework Provider
NuGet Package Manager
NuGet Package Manager

I closed and reopened Visual Studio 2013, and reopened the solution I had created. Now, when adding a Model as in step 2 of the article, I had Oracle options in the Data Source list!

an Oracle option is available
Oracle is now an option!

After selecting the Oracle option, you can complete setting up the connection as below. TNS is available as an option; if you use this, the connection string to Oracle must bu set up in your TNSnames file.

Connection Properties dialog box
Select your Oracle schema.

After this is done, you can continue with the linked tutorial above!

Cloning a Repository from the Command Line with Bonobo Git Server

git logo

I recently set up Bonobo Git Server on a Windows Server running IIS.

I implemented Windows Authentication for the Bonobo Web interface as per the instructions on the Bonobo site.

I created a repository called “Test” using the Web interface, which — assuming you use the folder names in the instructions — is at http://servername/Bonobo.Git.Server.Interface.

However, when trying to clone the Test repository at the command line, I was getting nowhere when putting in the username as “domain\username”, as is the usual convention in Windows.

The URL for cloning this repository using “git clone” is http://servername/Bonobo.Git.Server/Test.git. By entering the username as “username@domain” (all lowercase, no quotes) at the username prompt, and entering the user’s password at the password prompt, I was able to clone the repository.

While I did not try this, I think http://username@domain@servername/Bonobo.Git.Server/Test.git as the URL should work as well.

Scheduled Task to Ensure that a Windows Service is Running

Windows Server logo

Some applications running under Windows services do not always remain in the running state, even when there is no apparent reason that they should stop. This is often due to a bug in the application, or perhaps the connection with the database that was being used by the application was temporarily broken.

In my case, a third-party application that I support (with no control over its source code) has a service that stops without warning to the user from time to time. Regardless of the reason as to why the stop control was sent by the application, the service needs to be running all the time. If this service were stopping due to a crash in the service, Windows has options in the services dialog box that can automatically restart a crashed service, or restart the server itself. These options do not help me, as it is the application sending a stop command to the service. I needed a simple way to ensure that the service is always running. The following batch file, using the actual Service Name (not the Display Name) of the service in place of “ServiceName”, will start the service if it is not running, and do nothing otherwise.

@ECHO OFF
FOR /F "tokens=3 delims=: " %%H IN ('SC QUERY "ServiceName" ^| FINDSTR "        STATE"') DO (
  IF /I "%%H" NEQ "RUNNING" (
   NET START "ServiceName"
  )
)

By saving this as a batch file and setting up a Scheduled Task to run the file on a regular interval such as every five or ten minutes, this will minimize the necessity of manually restarting the service when it is shut down unintentionally, that is, without the intention of the application administrator. The task should be disabled when one needs to have the service shut down for maintenance or troubleshooting.