0

Hi,

I work on one project in ASP.NET MVC3. Everything worked fine, until I created new table Price_Ranges. I then tried to get data using LINQ, the following code:

IEnumerable<PriceRange> priceRanges = from pr in dbContext.PriceRanges
                                                    join cat in dbContext.Categories on pr.Category_Id equals cat.Id
                                                    where cat.Id==categoryId
                                                    select pr;

Then I use this IEnumerable in my view.
dbContext is EFDbContext class and everything is ok width it.

When I try to run this, it shows me exception:

System.Data.SqlClient.SqlException: Invalid object name 'dbo.PriceRanges'.

Is there anything I should do so asp.net recognize newly created tables in database?
How can I solve this problem.

Thanks in advance,

Amer

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by aldm
1

You have referred to the table as Price_Ranges and PriceRanges. Which one is correct? If it is Price_Ranges in the database then no, dbo.PriceRanges does not exist.

-1

hi dude

i think there is no table in that db. plz refer proper db accessed
another thing is rename dbo.PriceRanges to PriceRanges

0

Hi,

Thanks for answers.
hericles was right. I made a mistake in naming my table in code. I forgot "_" letter. It usually happens after 9 hours of coding.

Thanks you very much again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.