Advertise with us

EntityCommandExecutionException was unhandled see innerException for Details

Hi All,

I am trying to connect my C# application with SQL server compact edition using ADO.NET entity Model.

I think I have been successfully able to generate the model against the database schema.

However when I try to use the entity objects in code I get the

EntityCommandExecutionException` was unhandled error along with "An error occurred while executing the command definition. See the inner exception for details."

Here's the code

Database1Entities db = new Database1Entities();
var query = from item in db.People
                    select Name;
foreach (var item in query)
    MessageBox.Show("The name of the customer is " + item);

It says to check inner exception. When I did checked InnerException gave me the error

"InnerException {"A parameter is not allowed in this location. Ensure that the '@' sign is in a valid location or that parameters are valid at all in this SQL

statement."} System.Exception {System.Data.SqlServerCe.SqlCeException}"

Now I am entirely new to using entity framework for generating objects from database sachems. I would really appreciate some guidance in this regard.

Thanks in advance for any recommendations or solutions.
Last updated:6/19/2013 8:25:30 AM

1 Answers

Dev Patel
Dev Patel


The problem wasn't with entity framework or connection.

The problem was with your LINQ query.

The correct query as following

var query = from item in db.People
            select item.Name;

Last updated:6/19/2013 8:25:30 AM