Reputation: 204
I'm trying to create a controller to use a Linq to SQL class in VS2013. I created a SQL database and added a table called Alias with a fields and a primary key. I then proceeded to add a Linq to SQL class into my Models folder called Alias. I added the Alias table to the OR designer, saved the class and rebuilt the solution.
I clicked my Controllers folder and hit add controller MVC 5 with views using EF. This is where things got messed up, the data context for my Alias Linq to SQL class is missing. What am I doing wrong here? My only option with the Alias model class is to create a new data context class. If it's something to do with this template, what would be a default looking controller template for this Alias class?
Picture of the add controller dialog:
web.config connection string:
<connectionStrings>
<add name="URLDBConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\URLDB.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="AurlContext" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=AurlContext-20140221123357; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|AurlContext-20140221123357.mdf"
providerName="System.Data.SqlClient" />
</connectionStrings>
Upvotes: 1
Views: 1388
Reputation: 33071
Entity Framework (EF) is not the same thing as LINQ to SQL. You are trying to use scaffolding designed for Entity Framework, but the only thing you have is a LINQ to SQL context. This will not work.
If you are using the LINQ to SQL designer, you should be able to transition to Database First styled Entity Framework without too many headaches. To add a Database First context to your project follow these steps:
That said, I highly recommend you go with an EF "Code First" approach.
Upvotes: 5