title: How to use DbContext without using Edmx in C#?
body: <p>Can we use <a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext(v=vs.113).aspx" rel="noreferrer"><code>DbContext</code></a> without adding EDMX in project for Data model here is sample code in which I am trying to save <code>Instance</code> class object with the help of <code>ContextManager</code> which is <code>DbContext</code>.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data.Entity;
  using System.Data.Entity.Core.Objects.DataClasses;
  using System.Linq;
  using System.Text;
  
  namespace DbContext_test
  {
      public class ContextManager : DbContext
      {
          public ContextManager(string connstring)
              : base(connstring)
          {
          }
  
          public override int SaveChanges()
          {
              //TODO: Write code before saving dataEntity object or fire some event to do so.
              return base.SaveChanges();
          }
      }
  
      public class Instances : EntityObject
      {
          public int ID { get; set; }
          public string InstanceCode { get; set; }
          public string InstanceName { get; set; }
      }
  
      public class InstanceManager
      {
          readonly string ConnectionString;
  
          public InstanceManager(string connString)
          {
              ConnectionString = connString;
          }
          public void SaveInstance(int id, string instanceCode, string instanceName)
          {
              SaveInstanceInternal(new Instances { ID = id, InstanceCode = instanceCode, InstanceName = instanceName });
          }
  
          public void SaveInstance(Instances instance)
          {
              SaveInstanceInternal(instance);
          }
  
          private void SaveInstanceInternal(Instances instance)
          {
              var contextManager = new ContextManager(ConnectionString);
  
              contextManager.Entry(instance);
              contextManager.SaveChanges();
          }
      }
  }
  </code></pre>