Solved

Why does Entity Framework 4.0 require a recompile?

Posted on 2011-02-22
8
542 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
 
LVL 25

Assisted Solution

by:apeter
apeter earned 500 total points
ID: 34972301
You have a view to bind?what is your datasource?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now