Invalid object name 'dbo.Employees'.

Hi Experts

can't figure out why I have the error above. It occurs when I try to insert items in northwind db

the desinger.cs has this code

[Table(Name="dbo.Employees")]
public partial class Employees : INotifyPropertyChanging, INotifyPropertyChanged
{
      
I also noticed that when I dragged across the employee table, it was called employee and not employees (northwind has it has this)

thanks
protected void butAdd_Click1(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ToString();
        DataClassesDataContext dataContext = new DataClassesDataContext(connectionString);

        Employees emp = new Employees();
        emp.LastName = txtLastName.Text;
        emp.FirstName = txtFirstName.Text;
        dataContext.Employees.InsertOnSubmit(emp);
        dataContext.SubmitChanges();

        DataGrid1.DataBind();
        DropDownList1.DataBind();
    }

Open in new window

SirReadAlotAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tovvenkiCommented:
see if this post helps you
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_24365862.html

Thanks and regards,
Venki
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fernando SotoRetiredCommented:
Hi SirReadAlot;

If you open Server Explorer connection to the Northwind database and open the Table node what is the Employees table called? If it is the standard Microsoft Northwind it should be called Employees.

To find out what name it will be given in the model the file created by the ORM designer you need to look at the project options by Main Menu -> Tools -> Options... when the Options window opens click on the tree node Database Tools then O/R Designer and see what Pluralization is set to if set to True then Employees in the DB will become Employee in the model if set to False then Employees in the DB will become Employees in the model. From what you state I would expect that Pluralization is set to False.

What is Pluralization set to in your environment?
On what line of code does the error occur on?
Is this a compile error or Design error?

Fernando
0
SirReadAlotAuthor Commented:
m
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.