?
Solved

Invalid object name 'dbo.Employees'.

Posted on 2010-04-07
3
Medium Priority
?
1,282 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:SirReadAlot
3 Comments
 
LVL 21

Accepted Solution

by:
tovvenki earned 750 total points
ID: 30018146
see if this post helps you
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_24365862.html

Thanks and regards,
Venki
0
 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 750 total points
ID: 30024812
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
 

Author Closing Comment

by:SirReadAlot
ID: 31711766
m
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question