please let me know how make asp.net mvc with sql server.. i mean with out entity framework, and i am not supposed to use loacl database by importing database file. so i write connection string for sql server.. by this i want to do database opearations using DbContext..
here is my connection string
<add name="MyConnection" connectionstring="Data Source=v-rrd2005; User ID=sa;Password=pa55w0rd!;Initial Catalog=TrainingDB;Integrated Security=True" providername="System.Data.SqlClient">
but i am unable to connect sql server..
here is context.cs file
public partial class MyConnection : DbContext
{
public MyConnection()
: base("name=MyConnection")
{
// Database.SetInitializer<DbContext>(null);
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// throw new UnintentionalCodeFirstException();
}
public DbSet<EmployeeInfo> TrainingDB { get; set; }
}
here my EmployeeInfo is table name and TrainingDB is database name
my contorler page
public class GetEmpInfoController : ApiController
{
private MyConnection db = new MyConnection();
public IEnumerable<employeeinfo> GetEmployeeInfoes()
{
return db.TrainingDB.AsEnumerable();
}
public EmployeeInfo GetEmployeeInfo(int id)
{
EmployeeInfo employeeinfo = db.TrainingDB.Find(id);
if (employeeinfo == null)
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
}
return employeeinfo;
}
}
im unable to make connection to my sqlserver..