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
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
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.
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
0
käµfm³d 👽Commented:
When you drag/dropped from the data connection, was a MyDatabaseEntities class created for you? I suspect you don't have a class, and this is why you are getting the error. In other words, the class doesn't exist anywhere, so there is not assembly to reference.

It's been a while since I've worked with the Data Connections tab, so I'll try to recreate your steps later tonight (unless someone else chimes in with the appropriate answer).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
0
käµfm³d 👽Commented:
"MyDatabaseEntities" seems to be a kind of name that user specifies, is it not?
It would seem so, yes.
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.