Try something like
using (onlinequizEntities ob= new onlinequizEntities ())
{
Sub ob1 = new Sub();
ob1.Subject = txt_adminsub.Text;
if(!ob.Sub.Any(subject => subject.Subject == ob1.Subject))
{
ob.Sub.AddObject(ob1);
ob.SaveChanges();
}
}
Try and revert
PS : The best way is to set which ever Unique column as Unique Constraint in Table since the above
cannot ensure uniqueness in case of concurrent insertion or updations from different users.
Hope this helps...