Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5845307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:24:58+00:00 2026-05-22T12:24:58+00:00

I am new to .NET and LINQ to SQL. So far, I have been

  • 0

I am new to .NET and LINQ to SQL.

So far, I have been pulling data and populating a gridview, and everything is working fine.

However, when I built my second page, I created a new DataContext (I assumed using one per page) when I referenced a table that I used in my previous page, it gave me an “Ambiguous reference” error because I had my table in both DataContexts. After removing the table from the second, I could reference the one from my first.

So, should I have just one context for my entire application or one for each table? Maybe something in between where I put the tables that I mostly use together in the same context?

What is the best practice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:24:58+00:00Added an answer on May 22, 2026 at 12:24 pm

    In LINQ to SQL the DataContext serves as an abstraction of the database. If I’m understanding your question correctly, you had been using two separate classes that defined unique DataContexts per page? You need only one DataContext class that can be shared in the application. If you really wanted to, you could have multiple instances of the DataContext but I can’t think of when you’d want to do that.

    If you have code of how you’re accessing the DataContext and tables it would help.

    See the MSDN reference on the DataContext class – DataContext for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to asp.net and especially LINQ and SQL. Say I have a
I am new to Linq and previously have been using Ado.net classes. I want
i'm new to asp.net mvc. I'm displaying data from a linq to sql query
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)
I'm new at LINQ, searching the net for LINQ samples that mimic SQL's LIKE
I'm new to grails, but have previous experience using .net with c# and linq
I'm using LINQ to SQL in ASP.NET MVC. I wrote some new code to
Possible Duplicates: Is LINQ to SQL DOA? I am starting a new ASP.Net project
I'm familiar with .NET and with SQL. Now I'm looking at the new LINQ
I am new to asp.net and I am trying to learn Linq to SQL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.