Reputation:
For some reason I keep on receiving an Invalid Object Name error when trying to make an entry to a table in the database. This error began after adding a table to the database. After adding the table to the database I updated Entity Framework by right clicking and updating from database. I have read many posts referring to pluralization being the cause, however I do not believe that is the culprit in this case. I'm pretty new to ASP.NET, what else could be causing this error? Thanks, I will try to provide any information needed.
EDIT StackTrace
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[TResult](IEnumerable`1 sequence)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
at LogService60.ServiceObjects.BillingReport.SendToSQL() in C:\Utilities\LogParser\LogService60\ServiceObjects\Message.cs:line 144
Upvotes: 1
Views: 1818
Reputation:
I was too quick to post on here. Stupid mistake by me, I forgot to change the connection string in the config file to point to the development server that I changed the schema on. It was still pointing to the production server. Thanks everyone.
Upvotes: 1
Reputation: 31033
make sure you are refering to the correct name if you have a table name like Persons
when you add it to the designer it will become Person
so if you are querying the db like
var person = from p in DBContext.Persons ....
it will give you the error
instead you should use
var person = from p in DBContext.Person ....
Upvotes: 0