problem with newly created table in asp.net
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
aldm
Junior Poster in Training
55 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
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.
hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 168
hi dude
i think there is no table in that db. plz refer proper db accessed
another thing is rename dbo.PriceRanges to PriceRanges
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: 0
Solved Threads: 7
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
aldm
Junior Poster in Training
55 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0