Reputation: 31
I am trying to rename the Datacontext interface to NutshellContext but i kept getting this error written in my title. Here is the full code by the way. The error lies in the first code after the main function. My database table seems to be correct syntax.
[Table (Name = "Customer")]
public class Customer
{
[Column(IsPrimaryKey = true)]
public int ID;
[Column (Name = "Name")]
public string Name;
}
class NutshellContext : DataContext // For LINQ to SQL
{
public Table<Customer> Customers
{
get { return GetTable<Customer>(); }
}
}
class Program
{
static Main()
{
var context = new NutshellContext(@"Server=.\SQLEXPRESS;Database=master;Trusted_Connection=True;");
Console.WriteLine(context.Customers.Count());
}
}
Upvotes: 0
Views: 971
Reputation: 11025
The NutshellContext
class does not contain an explicit constructor, and hence, the default constructor for that class is a parameterless constructor. To make your code work, you need to create a constructor with the below signature:
public NutshellContext(string connectionString)
{
//Your logic
}
Upvotes: 1