Solved

Why does Entity Framework 4.0 require a recompile?

Posted on 2011-02-22
8
547 Views
Last Modified: 2012-05-11
I have a table in the database of column names and an int column in that table to hide or show the associated column. I use EF4 to use that table and a Lambda expression which successfully shows or hides the given table, which is shown my Dynamic Data web application.  But I see a strange phenomenon I need to work around.

I display the Dynamic Data web page grid which SHOWS the column, and that coincides with the fact that the show_state column has a value of 1.  When I change the value to 0 (zero) a page refresh does not hide the column and neither does a program restart.  I must recompile the program in Visual Studio and restart the program so that the column is then hidden, which is the correct behavior.

Why must I do this? I want a simple change of the value from 1 to 0 to hide the column on a page refresh.

Thanks,
newbieweb




0
Comment
Question by:newbieweb
  • 5
  • 3
8 Comments
 

Author Comment

by:newbieweb
ID: 34952609
It seems as though on recompile, Entity Framework takes a snapshot of the database, which does not change until the program is again recompiled.

Am I right about this?

If so, how can I stop this behavior?

newbieweb
0
 
LVL 25

Assisted Solution

by:apeter
apeter earned 500 total points
ID: 34961967
how ur saving it back/ and how ur they binding back?..please paste your code.
0
 

Author Comment

by:newbieweb
ID: 34962799
I am not changing the code via the Entity Framework. In another program, I am , and have no problems with data persistence. In this Dynamic Data website, certain table columns are hidden by way of changing an integer from 0 to 1. Then when I refresh the page, the column should become hidden, but it does not. I restart the program, and it's still not hidden. Last I recompile and then it is properly hidden from view.

So to answer your question, the database change is made using MS SQL Management Studio.
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 25

Assisted Solution

by:apeter
apeter earned 500 total points
ID: 34972301
You have a view to bind?what is your datasource?
0
 

Author Comment

by:newbieweb
ID: 34979277
I use MVC3 and my datasource is a DataStore object that wraps my Entity Framework 4.0 object.

I verify that when I stop then re-run my application, Session_Start is called again, which means the Session[] is getting the new instance. So clearly, that EF4 object exists and contains old data.

Is it on disk somewhere? Is there a property of EF4 to force a database hit?

Confused...

newbieweb
void Session_Start()
{
   HttpContext.Current.Session[Global.AdminDataStoreStr] = new AdminDataStore(UserLogin, Password);
}

Open in new window

0
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 34991391
can we see the AdminDataStore class's constructor which accepts UserLogin, Password as password?.  

Not very sure of MVC pattern...looks the source is not repopuplated. some how your build steps constructing the source. You have anything in post buid scripts in ur main project or  in entity project?
0
 

Author Comment

by:newbieweb
ID: 35007280
There's no magic here:

        public AdminDataStore(string userLogin, string password)
        {
            this.userLogin = userLogin;
            this.password = password;
            rddbEntities = new DEVEntities1();
        }

the object DEVEntities1 is the Entity Framework 4.0 object defined by the edmx file.
0
 

Author Closing Comment

by:newbieweb
ID: 35019219
Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question