I have a "junction" table that stores a user's userID (same userID that is in aspnet_membership table) and an ID for a product. I have added this table to a .dbml file. I am trying to do an insert into the table using LINQ and it's failing. Both fields in the junction table are set as primary keys, however, I do not have the aspnet_membership table in the .dbml file (nor do I have a relationship set between the two tables - it won't let me because the userID field in aspnet_membership is not a primary key). Here's my code (I have used similar code in other locations without a problem so I suspect the .dbml configuration is the problem). Any ideas why the inserts are failing?
bool success = false;
ASIStoreDataDataContext storeContext = new ASIStoreDataDataContext();
try
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
STOR_NewsletterUser newsSub = new STOR_NewsletterUser();
newsSub.SNWS_NewsLetterID = newsletterID;
newsSub.UserID = userID;
storeContext.STOR_NewsletterUsers.InsertOnSubmit(newsSub);
storeContext.SubmitChanges();
success = true;
}
}
catch { }
return success;