Solved

Why does Entity Framework 4.0 require a recompile?

Posted on 2011-02-22
8
543 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

947 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

22 Experts available now in Live!

Get 1:1 Help Now