28

I'm using C#, EF 4 in asp.net 4 and VS 2010.

I'm trying to load namespace System.Data.Linq with this code using System.Data.Linq and I receive this error:

Error 2 The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

Any idea what I'm doing wrong.

6 Answers 6

45

Right click your solution/project. Click Add Reference and search for System.Data.Linq and add the reference there and it should compile.

Sign up to request clarification or add additional context in comments.

2 Comments

If you use ReSharper, that tool will tell you which references you miss and will even add the references for you! [resharper]
I tried this by going into my reference manager of the project, and upon searching the term which you provided, it says No item found for search term . Any idea on what should I do to add reference.
11

Just to confirm that Adding the reference to the project didn't work for me because it was already selected.

However, selecting "Copy Local, True" in the Properties pane for the reference made it start working.

2 Comments

Same for me. Any idea why this extra step needs to be taken?
Doing this and then reloading the solution (I tried changing the target framework as stated below, but I didn't try just reloading the solution) did the trick. In my actual Class Library project this step was unnecessary. It was only necessary for a Web Application project.
5

That namespace is LINQ-to-SQL, so you'll also need to add a reference to System.Data.Linq.dll; it won't be added by default just by adding Entity Framework.

Comments

4

Try re-change target framework for your project.

Go to Proporties > Application > Target Framework change to another than used now, and next change it back.

Comments

3

VS Installer

VS Installer

The above answers didn't work for me, my problem was that I needed to add LINQ to SQL tools in Visual Studio.

3 Comments

Have you tried to run the Visual Studio as Administrator
This is exactly the problem for me. .Linq is not found if I run under my creds, but IS found if I open VS "run as Administrator". This sounds like trouble down the road, to me.
Please add a comment on how to get to that screen
-1

For VS 2022 and project on .NET 6.0 --- Project \ Referencies \ search \ MindBox.Data.Linq, everywhere "OK", install (based on personnel expirience)

Also, may be, need install -- Referencies \MS.System.Linq.Queryable (or MS.Queryable, not remember)

After all action LinqToSQL will be work in project.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
This was what I needed. Fixed all the issues I was having. Thank you!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.