To set it up so that a User has many Computers and a Computer has one User, you would do this:
class User {
public int idUser {get;set;}
public virtual ICollection<Computer> Computers {get;set;}
}
class Computer {
public int idComputer {get;set;}
public int UserID {get;set;} // automatically detected as a ForeignKey since the format it [classname]ID
public virtual User User {get;set;}
}
To set it up so that a Computer has many Users and a User has one Computer, you would do:
class User {
public int idUser {get;set;}
public int ComputerID {get;set;}
public virtual Computer Computer {get;set;}
}
class Computer {
public int idComputer {get;set;}
public virtual ICollection<User> Users {get;set;}
}
To set it up so that a User has one Computer:
class User {
public int ID {get;set;}
public virtual Computer Computer {get;set;}
}
class Computer {
public int ID {get;set;}
[Required]
public int UserID {get;set;}
public virtual User User {get;set;}
}
The [Required] tag should eliminate any errors about the one-to-one relationship
As a side note, the whole point of EF Code First is to make things super simple and quick and easy, but when you don't use some of the features it offers it diminishes it greatly and you have to do more manual work, which can lead to mistakes.
Here's a tutorial on how to do code-first. I recommend you read up on it.
Okay, I re-read your original question. You can't have both (one-to-one and one-to-many) between the same two classes, you can either have a one-to-one (i.e., a User has one computer and a computer has one user) or a one-to-many (i.e, a User has many computers and a computer has one user, or a computer has many users and a user has one computer.) It's a one or the other, not both, kind of thing. The fact that you think this is possible reinforces my statement that you really need to read that tutorial or read up on simple relational database structure