title: Linq to SQL vs Entity Data Model: Getting a stored proc to run
body: <p>Was I was previously messing with Silverlight and RIA, I was using a an ADO.NET Entity Data Model and domain context. I'm teaching myself how to run a stored procedure from RIA, and could not get it to work with the previous setup so I then started to try out using the <a href="http://www.csharpcorner.com/UploadFile/nipuntomar/958/Default.aspx" rel="nofollow noreferrer">LINQ to SQL</a> method. I did the following: </p>
  
  <ul>
  <li>Added the DBML</li>
  <li>Drag and dropped my table and example stored proc</li>
  <li>Saved the DBML and built and <em>rebuilt</em> the solution and project files.</li>
  <li>Create a Domain Service and attempt to add the dbml.</li>
  </ul>
  
  <p><strong>Here is my DBML</strong>
  <img src="https://i.stack.imgur.com/lyYSo.jpg" alt="alt text"></p>
  
  <p>Here is my error. The <em>Available DataContext/ObjectContext classes</em> list shows up empty. I have rebuilt many times and even have restarted visual studio. 
  <img src="https://i.stack.imgur.com/EkURR.jpg" alt="alt text"></p>
  
  <p>So here are my questions:</p>
  
  <ol>
  <li>Is there an easy way to do a stored proc with ADO.Net that I was missing therfore I could skip adding a LINQtoSQL class.</li>
  <li>Am I missing something really simple to add the dbml class and add a stored proc that way.</li>
  </ol>
  
  <p><strong>CODE</strong></p>
  
  <p>ZipCodeDataClasses.dbml.layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11, 8.5" name="ZipCodeDataClasses"&gt;
    &lt;DataContextMoniker Name="/ZipCodeDataClassesDataContext" /&gt;
    &lt;nestedChildShapes&gt;
      &lt;classShape Id="de7acfae-754b-4577-b227-3a33198fdc95" absoluteBounds="7.125, 2.375, 2, 1.3862939453125"&gt;
        &lt;DataClassMoniker Name="/ZipCodeDataClassesDataContext/ZipCode" /&gt;
        &lt;nestedChildShapes&gt;
          &lt;elementListCompartment Id="8744ad5e-7b77-4770-911d-6dc963876e40" absoluteBounds="7.14, 2.835, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /&gt;
        &lt;/nestedChildShapes&gt;
      &lt;/classShape&gt;
    &lt;/nestedChildShapes&gt;
  &lt;/ordesignerObjectsDiagram&gt;
  </code></pre>
  
  <p>ZipCodeDataClasses.designer.cs</p>
  
  <pre><code>#pragma warning disable 1591
  //------------------------------------------------------------------------------
  // &lt;auto-generated&gt;
  //     This code was generated by a tool.
  //     Runtime Version:4.0.30319.1
  //
  //     Changes to this file may cause incorrect behavior and will be lost if
  //     the code is regenerated.
  // &lt;/auto-generated&gt;
  //------------------------------------------------------------------------------
  
  namespace StoredProcedureTest.Web
  {
   using System.Data.Linq;
   using System.Data.Linq.Mapping;
   using System.Data;
   using System.Collections.Generic;
   using System.Reflection;
   using System.Linq;
   using System.Linq.Expressions;
   using System.ComponentModel;
   using System;
  
  
   [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="ZIPCODES")]
   public partial class ZipCodeDataClassesDataContext : System.Data.Linq.DataContext
   {
  
    private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
  
      #region Extensibility Method Definitions
      partial void OnCreated();
      #endregion
  
    public ZipCodeDataClassesDataContext() : 
      base(global::System.Configuration.ConfigurationManager.ConnectionStrings["ZIPCODESConnectionString"].ConnectionString, mappingSource)
    {
     OnCreated();
    }
  
    public ZipCodeDataClassesDataContext(string connection) : 
      base(connection, mappingSource)
    {
     OnCreated();
    }
  
    public ZipCodeDataClassesDataContext(System.Data.IDbConnection connection) : 
      base(connection, mappingSource)
    {
     OnCreated();
    }
  
    public ZipCodeDataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
      base(connection, mappingSource)
    {
     OnCreated();
    }
  
    public ZipCodeDataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
      base(connection, mappingSource)
    {
     OnCreated();
    }
  
    public System.Data.Linq.Table&lt;ZipCode&gt; ZipCodes
    {
     get
     {
      return this.GetTable&lt;ZipCode&gt;();
     }
    }
  
    [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.sp_GetCityByZip")]
    public int sp_GetCityByZip([global::System.Data.Linq.Mapping.ParameterAttribute(Name="ZIP", DbType="NVarChar(10)")] string zIP, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Return", DbType="NVarChar(26)")] ref string @return)
    {
     IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), zIP, @return);
     @return = ((string)(result.GetParameterValue(1)));
     return ((int)(result.ReturnValue));
    }
   }
  
   [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.ZipCodes")]
   public partial class ZipCode
   {
  
    private string _City;
  
    private string _State;
  
    private int _Zip;
  
    public ZipCode()
    {
    }
  
    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_City", DbType="VarChar(25)")]
    public string City
    {
     get
     {
      return this._City;
     }
     set
     {
      if ((this._City != value))
      {
       this._City = value;
      }
     }
    }
  
    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_State", DbType="VarChar(2)")]
    public string State
    {
     get
     {
      return this._State;
     }
     set
     {
      if ((this._State != value))
      {
       this._State = value;
      }
     }
    }
  
    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Zip", DbType="Int NOT NULL")]
    public int Zip
    {
     get
     {
      return this._Zip;
     }
     set
     {
      if ((this._Zip != value))
      {
       this._Zip = value;
      }
     }
    }
   }
  }
  #pragma warning restore 1591
  </code></pre>