You can pass the Context to the constructor when the SSDModel
object created,
public class SSDModel
private ddms_dataEntities2 db;
public SSDModel(ddms_dataEntities2 context){
db=context;
}
public ssd searchbyId(string id)
{
return db.ssd.FirstOrDefault(d => d.ssd_id_text == id);
}
public void add(ssd item)
{
db.AddTossd(item);
}
}
And when you are going to initialize sevaral model classes just create one context and pass that for all constructors.
var ddms_dataEntities2 db = new ddms_dataEntities2();
SSDModel ssd=new SSDModel(db);
OtherModel other=OtherModel(db);
One easy way to keep the context per request is describerd here
Or else you can use IOC containers.