Linq to SQL Issues

R

Roshawn

Hi,

I'm having a bit of trouble with the DataContext class that was generated when I dragged
tables from my database into the Linq to SQL designer. The problem is that no code is
generated for the DataContext class. All that's generated is an empty partial class with
nothing in it.

Is there supposed to be code in this class or must I manually put code in it? I thought
the DataContext class automatically generated code based on the tables I supplied. What
gives? :(

Roshawn
 
L

Lloyd Sheen

Roshawn said:
Hi,

I'm having a bit of trouble with the DataContext class that was generated
when I dragged tables from my database into the Linq to SQL designer. The
problem is that no code is generated for the DataContext class. All
that's generated is an empty partial class with nothing in it.

Is there supposed to be code in this class or must I manually put code in
it? I thought the DataContext class automatically generated code based on
the tables I supplied. What gives? :(

Roshawn

Just looked at one in one of my projects.

In the datacontext class there are
#Region "Extensibility Method Definitions"

followed by Partial Private Sub's with no code?

If you are missing those then you need to ensure that primary keys exist for
each table you want in the datacontext.

Only other code is about 5 New subs.

LS
 
R

Roshawn

Lloyd, thanks for the reply.

I had to look a little closer to find the file that actually contained some code. In the
Linq to SQL designer, I just right-clicked the background or one of the entity tables and
selected "View Code," which then brought up the .vb file. Only partial class declarations
for each table/entity I'm working with appeared and nothing more.

Fortunately, I found the *.designer.vb file which had actual code for the DataContext
object. Also there's code for the entities I'm working with.

Thanks again for your help. Now it's on to testing.
 

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