?
Solved

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

Posted on 2014-07-11
6
Medium Priority
?
4,175 Views
Last Modified: 2014-07-11
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
0
Comment
Question by:Mike Eghtebas
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40191117
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
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40191188
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
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40191202
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40191219
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40191222
"MyDatabaseEntities" seems to be a kind of name that user specifies, is it not?
It would seem so, yes.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40191452
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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question