Unable to load the specified metadata resource

I ran into this dastardly error while working on a utility to mass-update connection strings: Unable to load the specified metadata resource.

The problem was the Entity Framework connection string. Take this connection string, which uses an Oracle format:

metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string='Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle-host)(PORT = 1521))(CONNECT_DATA=(SERVICE_NAME=server-name)));User Id=Snoopy;Password=CharlieBrown;'

In three different places, you see the string “Models.Model1”. This is where my attempt went wrong. Different applications have different model names, so while this application has “Models.Model1”, another may have a different, equally creative name like “Models.Model2”. Once I corrected this, my connection worked.


Leave a comment

jQuery autocomplete appears behind Bootstrap modal window

I sure do love those Bootstrap modal popup windows. I use them all the time. They make me feel cool when I use them, and increase my self-esteem greatly. It’s like getting a participation medal when you’re the last place team in soccer, or a more fun sport.

Almost as much as modal popups, I love jQuery autocomplete lists, where you can enter a bit of text and have results returned from the database. Wow, those are fun to play around with. And users love them, too.

Alas, when I tried to bring my two favorite coding snippets together like a Reese’s peanut butter cup, things didn’t turn out well. Here is what the results looked like:

Completely unacceptable – half my list is hidden, and the rest are basically greyed-out. There was much sorrow and gnashing of teeth.

The key to fixing it was the “ui-front” class of the jQuery-ui.css file. Who knew such a small class could bring such happiness? To use the class in this instance, I needed to attach it to the DIV tag containing my textbox, like so:

<div id=”addEmployeeModal” class=”modal fade” role=”dialog”>
   <div class=”modal-dialog”>
      <div class=”modal-content”>
         <div class=”modal-header”>
            <button id=”modalClose” type=”button” class=”close” data-dismiss=”modal”>&times;</button>
<h4 class=”modal-title text-center”>Add employee</h4>
<div class=”modal-body ui-front“>
@Html.TextBox(“Employee”, null, new { @class = “form-control” })
<input type=”button” value=”Save” onclick=”functionToCallAutocomplete()  />

Now you, too, can enjoy the peanut butter and chocolate joy of using a Bootstrap modal popup and jQuery autocomplete controls.

Leave a comment

The MVC model is null when posting

I had an MVC view that I was using to update my data using a POST method by using a Bootstrap modal popup window. Everything seemed fine, but when I put a breakpoint in my controller action, my model was null. My very simple action:

       public ActionResult Update(Coaster model) {
           return View();

I’m going to give away the ending. The problem was that my form didn’t have the “name” property attached to the “input” tag. I thought the “id” property would be enough to send my model from the view to the controller, but it wasn’t. So instead of this:

<input type="text" id="Code" class="form-control" />

I had to have this:

<input type="text" id="Code" name="Coaster" class="form-control" />


Leave a comment

jQuery DatePicker – Removing time from a DatePicker control

I had an MVC view with a TextBox control binding to a model property

@Html.TextBoxFor(model => model.Date, String.Empty, new { @class = "form-control" })

This control was bound to a jQuery DatePicker control:

    $(document).ready(function () {
            minDate: 0

My problem was that when the model was bound from the database, the DatePicker would also show the time, not just the date like I wanted:









The fix for this is to make the second parameter a format string with only the date:

@Html.TextBoxFor(model => model.IssueDate, "{0:d}", new { @class = "form-control" })

Leave a comment

Updating an Oracle LONG column

Want to update an Oracle LONG value? Having problems? Well, you’re in luck. Do update the field, run this bit of code. Yes, it’s not an lovely as a one-line UPDATE statement, but sometimes, you have to do it the ugly way:

 coasterDesc varchar2(5000); 
 coasterDesc := 'Some really, really, REALLY long text goes here.';
 UPDATE coasters SET coaster_description = coasterDesc WHERE coaster_id = '12345'; 

Leave a comment

Web API getting 404

When trying to perform a simple GET request using Web API in my MVC application, I was getting a 404 message. I was accessing it through Ajax, and the URL was correct:

        url: 'http://localhost:1234/api/UserApi',
        type: 'GET',
        cache: false,
        contentType: 'application/json'

The problem was actually environmental. At a particular job site, the machines were locked down, including not being able to run PowerShell command – thus, an impediment to using NuGet. So I had to do several things to get my project working, but hopefully, if you’re having a similar issue, one of these is the key for you.

Several DLLs needed to be replaced, as the version were too old:

  • System.Net.Http
  • System.Net.Http.Formatting
  • System.Web.Http

The WebApiConfig.cs file was missing from the App_Start folder, so I added it:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;

namespace ScottProject.App_Start {
    public class WebApiConfig {
        public static void Register(HttpConfiguration config) {

                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }

The Global.ascx.cs file was missing the referene to the WebApiConfig file:

     protected void Application_Start() {
         // Other file snipped out

So this particular situation was specific to my situation, but perhaps one of those issues will help someone else.

Leave a comment

Slow multiple jQuery autocomplete fields

I’m a fan of the jQuery autocomplete control. I had a page that worked great with one autocomplete control, but after I added a second, that second control was horribly slow (the first was unchanged). Both controls were defined similar to the one here:

    source: function (request, response) {
        if (request.term.length < 4) {
        var coaster = new Array();
            async: false,
            cache: false,
            type: "POST",
            url: uri + "MyControll/Autocomplete",
            data: { "term": request.term },
            success: function (data) {
                for (var i = 0; i < data.length ; i++) {
                    customer[i] = data[i];
    select: function (event, ui) {

In order to get the second control to respond within a reasonable period of time, I added this code to the end of the Ajax method, which resolved the problem:


        })._renderItem = function (ul, item) {
            return $("<li></li>")
                .data("item.autocomplete", item)

Leave a comment