infolink

Wednesday, December 29, 2010

LINQ to SQL DataContext is not accessable, does not show even in intellisense

I have been seeing this strange behavior using LINQ to SQL in Visual Studio 2008 in the last two months.

I was working on a project and defined my DataContext using the LINQ designer. I applied the same namespace as my main class, yet in my main class I do not see my data context, and when I try to type it, it states it does not exist. I check the backend code of the LINQ designer and everything looks right, same namespace and the DataContext is named properly.

I played around trying many things to no avail, so as a last ditch effort I reinstalled Visual Studio 2008 SP1.

When I went back into Visual Studio 2008 I tried to type out my DataContext variable and still same issue, it wasn't accessable. So I then deleted my LINQ to SQL class.

I now recreate my LINQ to SQL class. Add my stored procedures, save the DataContext and then back to my class and guess what, it is there.

So, now here I am, different machine, a month later, same exact issue on a ASP.NET Web Application in Visual Studio 2008. It would not see my Data Context. So I repeat the steps that fixed it for me before in the follow order:

#1 Reinstalled Visual Studio 2008 SP1 (Yes, on both machines I had already installed Visual Studio 2008 SP1)

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en

#2 Open project back up and delete the Linq To SQL class

#3 Recreate the LINQ to SQL class in the designer

#4 Save and Recompile

That was it, it is now working as expected on this machine also, very strange, hope this helps someone else. The other project type was a ASP.NET Web Service.

No comments:

Post a Comment

Amazon1