I have Silverlight Application. Getting started with Linq I find out I have to make mapping in a new project in the entire solution. To use generated classes from new project I use “Add Reference”. For Silverlight Application it is possible to add reference only to the same kind of Project.
Here I got the problem because in Silverlight Applications it’s impossible to right-click on the project Add ->New Item -> LINQ to SQL Classes.
Perhaps entire idea of using classes from different Projects is stupid in this situation… Please help =)
Firstly, you won’t be able to use Linq-to-SQL in silverlight, as silverlight will never be able to connect directly to SQLServer. The only way to use Linq-to-SQL with Silverlight would be to create a service on your web server (WCF or something else) that uses L2S. Silverlight will then communicate with the service which in turn will communicate with SQLServer.
An easy way to share code between Silverlight and a non-Silverlight project is to share the files, rather than a binary reference (which is what you are trying to do). Select Project->Add Existing Files… from the original project. That way, the original project will compile in its format, and Silverlight will compile the same code into its format.
You might want to look at WCF RIA Services if you want to do data access from a Silverlight application, it simplifies the process a lot, and generates the services I mentioned above for you.