I'm trying to use the code below to add an entry in the 'UserAlertSubscriptions' table in my db which just links users to alertconfigurations.
The problem is that although i get no errors the entry does not get added to the database.
Any idea what i'm doing wrong. As you can see, I tried ApplyAllChanges, but this made no difference.
AlerterDataEntities alerterDataEntities = new AlerterDataEntities()
// get current user
User user = alerterDataEntities.Users.Where(u => u.UserID == 1).ToList<User>()[0];
// get selected alert configuration
AlertConfiguration alertConfiguration =
alerterDataEntities.AlertConfigurations.Where(a => a.AlertConfigurationID == 3).ToList
<AlertConfiguration>()[0];
UserAlertSubscription userAlertSubscription = new UserAlertSubscription
{
User = user,
AlertConfiguration = alertConfiguration
};
user.UserAlertSubscriptions.Add(userAlertSubscription);
//alerterDataEntities.AcceptAllChanges();
alerterDataEntities.SaveChanges();
var user = alerterDataEntities.Users.First(u => u.UserID == 1)