Linq To Sql-Beginners Q: can't Add new record (Add() method missin

G

Guest

Hello:

Downloaded VS2008 trial from MS 24 hours ago in order to investigate Linq To
Sql.
But I'm hitting a strange roadblock, where I am unable to find an Add()
method on the dataContext's tables... And without, I can't add a new record.

What I have done:

a) As I said, its a trial version of VS2008 (although I thought it was all
open for 90 days)
b) Deleted VS2005 as I was running out of space.
c) Which damaged VS2008, so I did a full Repair...(you'll see in a second
why I mention all this)


d) New Console project
e) Created new Database1.MDF, and Cancel last step in order to not create
any datasources as I don't need them.
f) Create two tables (Task, TaskType) in Db.
e) Create constraint in between two.
g) Save changes to db.
h) Drag both tables onto LinqToSql designer surface
i) Save it.

Right... at this point I have a DataContext, and have Entities.
Should be able to do the following:

string connectionString =
Properties.Settings.Default.Database1ConnectionString;
MyDb context = new MyDb(connectionString);

Task t = new Task();
t.Subject = "A new task";

context.Tasks.Add(t);

Every single example I've seen shows the Add() method...
except, my Tasks doesn't offer it. It offers Aggregate<>, All<> ,
Any<>....but no Add() method.

Other unexpected behavior...

Right click on a table in the designer, and the Insert, Update, Delete
methods are grayed out and offer no '...' to edit them. ...which is again
unlike the description in the MSDN docs and Scott Guthries example articles.

so.
a) Is it an VS install issue and i have to start all over again?
b) Is it a settings issue that I've unset accidentally?
c) Is it a gormless thing that's right in front of me, but I can't see?
(Most probable reason?)

Anyway -- any suggestions on how to move forward again?

PS: Is there a dedicated LinqToSql newsgroup?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top