The way I see your code, I would make a few changes before even rerunning the application,
public async Task<ActionResult> Create([Bind(Include = "Id,Name")] Student student)
{
var show = db.Students.Select(e => e.Name).ToList();
if (show.Contains(student.Name))
{
ModelState.AddModelError("Name", "Name already exists");
}
This would be a proper way to do this, why? Because, previously you were trying to check a list against a temporary variable which would typically return
object
type data. I am unsure as to why that resolved to true.
There is another approach to this kind of behavior,
var show = db.Students.Where(e => e.Name == student.Name).ToList();
if(show != null && show.Count != 0) {
} else {
}
Perhaps, this approach would solve your problem here.