views:

424

answers:

1

I added this code below:

public partial class Form1 : Form
{
    TestAdonetEntity2Entities entityContext;
    public Form1()
    {
        InitializeComponent();
        entityContext = new TestAdonetEntity2Entities();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
       dataGridView1.DataSource =  entityContext.SelectMyCustomer();
    }
}

But this code will cause an error:

public global::System.Data.Objects.ObjectResult<MyCustomer> SelectMyCustomer()
{
     return base.ExecuteFunction<MyCustomer>("SelectMyCustomer");
}

The error is:

An error occurred while executing the command definition. See the inner exception for details.

My stored procedure...:

ALTER procedure [dbo].[proc_MyCustomer]
as
begin
  select * from  dbo.MyStuffs
end

My Columns: CustomerID PK ink
Name nvarchar(50)
SurName nvarchar(50)

+1  A: 

Here's an MSDN article about using sprocs in Entity Framework.

And another one.

DOK