The query I'm using is this:
int? UserId = db.StudentModel//the question mark here makes the int nullable
.Where(c => c.UserName == certUserName)
.Select(c => c.UserId)
.First();
Unfortunately, this only works if the database has a primary key. Because of the specific structure and use of the database, there can't be a primary key. How do I modify my search to pull the exact same thing from the database even though there isn't a PK?
EDIT: Sorry! I should've been more explicit. I guess the error itself doesn't lie with the actual query, it lies with the way the models are set up:
One or more validation errors were detected during model generation:
IronGriffin.Models.CompletionsModel: : EntityType 'CompletionsModel' has no key defined. Define the key for this EntityType.
Completions: EntityType: EntitySet 'Completions' is based on type 'CompletionsModel' that has no keys defined.
That being said, the issue is still that there's no primary key defined. I imagine that this would all be functional if the search didn't function by searching the primary keys (unless it doesn't? I thought I read somewhere that that's how it works)