Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

The type or name space name MyDatabaseEntities could not be found... C#

I have the following code to populate a chart:
      private void populateReport()
        {
           using (MyDatabaseEntities dc= new MyDatabaseEntities())
            {
                var v = dc.SqlDataSource1.Tolist();

                GridView1.DataSource = v;
                GridView1.DataBind();

                Chart1.DataSource = v;
                Chart1.DataBind();
        }
    }

Open in new window

(used example at: https://www.youtube.com/watch?v=KOV3Z0PaMVs)

Using vs2010, instead of creating data entity (as described in this video), I just dragged and dropped the table on my page thus automatically creating  SqlDataSource1 on my web form. The reason I was forced to do this drag and drop was my menu options in vs 2010 didn't match thoese displayed on the demo video.

As shown on the attached image, I get some errors at line 3 saying "The type or name space name MyDatabaseEntities could not be found (are you missing a using directive or an assembly reference?)"

Clearly, I am have using directive but as to how to make assembly reference, I am not sure how it is done.

The demo is seemingly in a later version of visual basic.

Question: How can I correct this error?

Thank you.
TypOrNameSpace.png
Avatar of kaufmed
kaufmed
Flag of United States of America image

Try clicking on either MyDatabaseEntities reference such that the caret ends up on the text. Then hit Ctrl-period. A small popup menu should appear that shows you options for correcting the error.
Avatar of Mike Eghtebas

ASKER

kaufmed,

Nice portrait. I have never seen this before.

Using Ctrl-period, as shown on the first attached image, I can proceed with two options:

- Generate class for 'MyDatabaseEntities', and
- Generate new type...

I used the Generate new type and added it to the current file. Now I have two errors as shown on the 2nd attached image.

Question: How can I handle these two erros?

Thanks,

Mike
TypOrNameSpace2.png
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I searched for "MyDatabaseEntities" string. There is none other than what I have used.

"MyDatabaseEntities" seems to be a kind of name that user specifies, is it not? Or this is a known class/ object in C#?

I also need to re-learn how to generate entity model using other option than drag and drop.

Mike
"MyDatabaseEntities" seems to be a kind of name that user specifies, is it not?
It would seem so, yes.
Add/New Item/ on the project gives me to add ADO.NET Entity Data Model to save my database as MyDatabase.edmx

And then, as I am working on the connection to show what tables I want to include with this model, it automatically adds "Entity" thus it becomes MyDatabaseEntity.

I managed to make it work.

Thank you for the help.

Regards,

Mike