SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 participate in relationship
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mamor90
Starting Member

Sweden
5 Posts

Posted - 03/16/2013 :  10:46:03  Show Profile  Reply with Quote
I am trying to save to the database tables "Employee" and "Employee_languages" I am recieving this following error (upon saving?)
Entities in 'knowitCVdbEntities.EMPLOYEE_LANGUAGES' participate in
the 'FK_EMPLOYEE_LANGUAGES_EMPLOYEES' relationship. 0 related 'EMPLOYEES' were found.

1 'EMPLOYEES' is expected.

This is my method for saving

public void setEmployee(string fileName)
    {

        var emp = new EMPLOYEE
                      {
                          firstname = TextBoxFirstName.Text,
                          lastname = TextBoxLastName.Text,
                          about = TextBoxAboutYou.Text,
                          phone = TextBoxPhone.Text,
                          position = TextBoxPosition.Text,
                          email = TextBoxEmail.Text,
                          username = TextBoxUsername.Text,
                          date_of_birth = TextBoxDateOfBirth.Text,
                          image = FileUploadPicture.FileName
                      };
        var emplanguages = new EMPLOYEE_LANGUAGES();
        {
            emplanguages.language_name = ListBoxLanguages.Text;
            
        }

       

        var db = new knowitCVdbEntities();
        db.AddToEMPLOYEES(emp);
        db.AddToEMPLOYEE_LANGUAGES(emplanguages);
        db.SaveChanges();
}

I was under the assumption that my code was correct, but there must be something wrong. What seems to be the issue here?

James K
Flowing Fount of Yak Knowledge

3744 Posts

Posted - 03/16/2013 :  21:41:56  Show Profile  Reply with Quote
Is there a foreign key relationship between EMPLOYEE_LANGUAGES and EMPLOYEE, or perhaps is there a link table that has EMPLOYEE ID and LANGUAGE ID? Look at the tables in the database using SSMS - that is the only way I can think of to figure out what is going on (and perhaps the simplest).
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000