Tom el Safadi
Tom el Safadi

Reputation: 6766

Asp.Net 5 missing Linq to Sql class

How can I add a Linq to Sql file in Microsoft Asp.Net 5 with Mvc 6. see the screenshot below. There is no way where I can find this Linq to Sql file. As well there is no C# tab at the side??

enter image description here

When I open the project on Asp.Net 4 with Mvc 5 there is this C# tab, as well as the Linq to sql file.

Upvotes: 3

Views: 3651

Answers (1)

Nick De Beer
Nick De Beer

Reputation: 5262

Duplicate here, however I've tried to add more step by step instructions so that it could help you and others.

Right click on src and Add > New Project. Select Class Libarary. Take note of the .NET Framework (I'm using 4.6 here), as you will have to match that with your main project.

Add new project

The class library should appear in your solution.

Solution Explorer

Right click on the class library (or a sub folder where you want the Linq To Sql Classes), and Add > New Item. In the data tab (on the left), it should have the item LINQ to SQL Classes

Add Linq To Sql Classes

Configure your LINQ to SQL.

LINQ to SQL

In your main asp.net-5 web application, make sure your project.json is setup so that it's using the same .NET Framework as your Class Library (check first step). I'm using 4.6 here.

"frameworks": {
    "dnx46": {
    }
},

Still in your main asp.net-5 solution, right click on References > Add Reference.

Add Reference

Add the Class Library reference.

Reference

I hope this helps.

Upvotes: 4

Related Questions