Reputation: 3040
I have a simple relation between a User model and a Role model.
public class User {
{
public User() {
Roles = new HahSet<Role>();
}
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
public class Role {
public Role()
{
Users = new HashSet<User>();
}
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public virtual ICollection<User> Users { get; set; }
}
On my development system, when querying user.Roles, I get the intended result of 3 Roles. When deployed to a test environment, the same query returns 0 Roles.
I have logged and monitored both environments. Both systems
As far as I can, my environment and configs are identical.
My question is, what sort of environmental and/or configuration areas can I investigate to work out what is happening in the test environment?
Upvotes: 0
Views: 81
Reputation: 352
To be on the safe side can you just verify the two objects.. They have to look something like this...
public class User {
{
public User() {
Roles = new HahSet<Role>();
}
[Key]
public int UserId { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
public class Role
{
[Key]
public int RoleId { get; set; }
[ForeignKey("User ")]
public int UserId { get; set; }
public User User { get; set; }
}
Upvotes: 1