Share Same DbContext between web role and worker role

HI
My "Windows Azure Cloud Service" project consists of one web role (.NET MVC) and one worker role, they are working fine under "Emulator".
The web role project is orginally a Azure web site application which is converted to a web role project and the connectionstring is located in the web role application
http://thinkfirstcodelater.com/blog/?p=1922
When I try to access the dbcontext in worker role like this
public override void Run()
            // This is a sample worker implementation. Replace with your logic.
            Trace.TraceInformation("CCDWorker entry point called", "Information");
            while (true)
                Thread.Sleep(50000);
MyContext context = new MyContext();
                List<MyEntity> ccds = context.MyEntity.ToList();
                Trace.TraceInformation("Working", "Information");
I got this exception: "The model backing the context has changed since the database was created." Please help
Regards
Mark

Hi Mark,
Thanks for posting!
Like jeff said in this blog(http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx ),When a model
is first created, we run a DatabaseInitializer to do things like create the database if it's not there or add seed data. The default DatabaseInitializer tries to compare the database schema needed to use the model with a hash of the schema stored in an EdmMetadata
table that is created with a database (when Code First is the one creating the database). Existing databases won’t have the EdmMetadata table and so won’t have the hash…and the implementation today will throw if that table is missing. We'll work on changing
this behavior before we ship the fial version since it is the default. Until then, existing databases do not generally need any database initializer so it can be turned off for your context type by calling:
Database.SetInitializer<YourDatabaseContext>(null);
Also, you could refer to this thread,http://stackoverflow.com/questions/3600175/the-model-backing-the-database-context-has-changed-since-the-database-was-crea
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Scaling of VM Roles and Worker Roles, why divide by total?

    I am trying to tweak with the auto-scale settings and it is my understanding that the CPU load is divided among the total number of instances within the Role.
    I get this in concept. 
    However, what I am seeing is that if I have two instances in my availability group, and I have one instance running.  That if I set the CPU load slider too high, my new instance never turns on / provisions.
    It is as if the calculation is always averaging among the total possible - therefore if one is at 100% CPU, then that equates to 50% CPU.  And if my slider is set to 60%, my second VM never turns on. (I left it running all night this way once to see).
    Where what I think the slider should mean is that I never want a single instance to go beyond 60% utilization, if it does then give me another instance.
    Am I following this properly?
    Since I only have the scaling metric of CPU (since I don't have a Service Bus queue) I have to use it wisely and make sure that it reacts when appropriate - and in my case I might want it to scale out at 40% to ensure that there is no negative
    user experience.
    And right now, I am not seeing that I can make that happen.
    Brian Ehlert<br/> http://ITProctology.blogspot.com<br/> Learn. Apply. Repeat. <br/&gt

    hi
    autoscaling per CPU is compared with the average CPU usage of all instances of the role.
    so if you set the bottom bar is 20% and have 2 instances running there with CPU usage 37% and 4%, azure fabrci will autoscale it to 3 instances, because average cpu is 20.5% and beyond the bottom bar.
    actually, autoscaling based on cpu works as below:
    All instances are included when calculating the average percentage of CPU usage and the
    average is based on use over the previous hour. Depending on the number of instances that your application is using, it can take longer than the specified wait time for the scale action to occur if the wait time is set
    very low.
    As a result, if you have an app that is at 0% load, and then start running a load test to make it go to 100% (and have a scale-up target of 80%) it will take at least 45 minutes before
    the scale action will start. However, this is not a typical real-world scenario. It’s more likely that your load is already high (say 75%). In this scenario, it would take much less time to trigger the scale action.
    One of the reasons that we do an hourly average is, with the current platform, it’s impossible to get metrics from Virtual Machines  or Cloud Services under a 15 minute latency.
    So, if we scaled based just on the last 5 or 10 minutes, we would never have data to scale on. You can see this in the screenshot below, it was taken around 5:30, but the most recent data point is at 5:15.
    In the future, the azure platform is looking at ways to speed up metric collection, but this is likely not coming for quite some time. As a result, the best we can do is a rolling
    average over a larger time window.
    let me know if there is any question.
    best regards
    Jian

  • August 2014 Scheduled Maintenance - Are Web and Worker Roles affected?

    Are Web and Worker Roles affected by the Scheduled Maintenance that will be performed on Aug 2, 2014?  The email that I received from Microsoft Azure states that it will affect VMs and Cloud Services and goes on to say how to keep your VMs available
    despite the maintenance by setting up Availability Sets for VMs, but does not mention a strategy for Web and Worker roles.
    What am I missing here?

    Hello Farid_Azure,
    Yes, the Web and Worker Roles are also affected by the scheduled maintenance as the web roles and worker roles are residing on the hardware that will go on maintenance.
    The Cloud Service deployments will also reboot during the maintenance. You can increase the number of instances running for your web roles and worker roles to avoid being affected:
    http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-scale/#manualscale
    I hope that this answers your question.
    Thanks,
    Syed Irfan Hussain

  • How to share the same session between JNLP Application and browser session

    How to share the same session between JNLP Application and browser session using BasicService.showDocument(url) method? It appears whenever i launch any URL from within a JNLP application using BasicService.showDocument(url) , it creates new instance of browser and session even after i used cooke handlers to restore JSESSIONID and Ltpa token etc.
    public static int showDocument(String urlToOpen)
    BasicService obj = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
    obj.showDocument(urlToOpen);
    }

    Try using Reflection

  • What are Azure limitations for Websockets in Cloud Services (web and worker role)?

    A WebSocket Server should be built on Azure platform with OnPrem connections and have questions regarding limitations for Websockets in Azure Cloud Services - web and worker roles.
    Websockets can be configured for Web Sites and limitations are understood, but Azure Websites is not an option. 
    Nevertheless it is planned to run a web service (without UI - no web site) as a Cloud service which has secure websocket (WSS) connections to OnPrem machines. Websocket protocol is enabled for IIS8 on Cloud services web and worker roles. Azure Service Bus Relay
    is not an option.
    Questions:
    1) Are Websockets supported for Azure Cloud services web and worker roles? we assume yes
    2) What are potential limitations from Azure side to support concurrent Websocket connections? We are aware that CPU, memory etc are limitations, but are there additional limitations from MS Azure side? 
     

    Hi,
    As I know, azure cloud service web and worker role support Websockets, users can connect to the role via the special endpoint, if we use Azure cloud service, I think we can monitor the metrics such as CPU, memory, etc... and scale our cloud service via these
    metrics to keep the websockets working, refer to
    http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-scale/ for more information about how to scale a cloud service.
    Regards

  • How the hell does a person share session data between JSP page and a Servle

    1. How the hell does one share session data between a servlet and a JSP page without using a bean but rather using a normal string variable.
    2. When using session scope to access a bean the application complains about not finding the bean on the specified scope, however when I use an application scope the save the same bean, the application does find it.
    Please help!!!!!!!
    SERVLET:
    HttpSession session = request.getSession(true);
    ServletContext servletContext = session.getServletContext();
    customerID = result.getString("CustomerID");
    userName = result.getString("UserName");
    session.setAttribute("UserName",userName);
    session.setAttribute("CustomerID",customerID);
    System.out.println("Customer UserName = " + session.getAttribute("UserName"));
    response.sendRedirect("/economics/subscriptions/default.jsp");
    JSP PAGE:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root xmlns:jsp=http://java.sun.com/JSP/Page mlns:c="http://java.sun.com/jsp/jstl/core" xmlns:sql="http://java.sun.com/jsp/jstl/sql" version="2.0">
    <jsp:directive.page isThreadSafe="true" session="true" contentType="text/xml"/><jsp:output omit-xml-declaration="false"/><jsp:scriptlet>response.addHeader("x-xslt-nocache", "true");</jsp:scriptlet><pml>
    <page type="web" search="y">
         <pageName>Commercial Banking</pageName>
         <jsp:directive.include file="/economics/header.inc"/>
         <jsp:directive.include file="/login.inc"/>
         <jsp:directive.include file="/economics/leftMenu.inc"/>
         <!--<jsp:useBean id="UserName" type="java.lang.String" scope="session" />-->
         <content>
         <searchSum>Commercial - Main Content</searchSum>
         Value = <c:out value="${request.session.getAttribute("UserName")}"/>
         </content>
         <jsp:directive.include file="/economics/rightNav.inc"/>
         <jsp:directive.include file="/footer.inc"/>
    </page></pml></jsp:root>

    For a start, just "session" instead of "request.session" would work better. But why did you post this here and not in the JSP forum? Doesn't seem to have anything to do with Java programming.

  • Are there any links between HR organisation and user roles in R12

    Hi
    Do you know if there are any links between HR organisation and user roles i.e. can a role be assigned to an organisation in R12?
    Thanks
    Sean

    The thread stack sizes also depend on the type of threads you are
    working with.
    If you are working with POSIX threads :
    % man -s 3C pthread_create
    or if you are working with Solaris threads :
    % man -s 3C thr_create
    For these 2 cases, the default stacksize is 1MB for a 32-bit process.
    If you do not wish to use this default value, the man pages show
    you how to change this size in your code.
    There is a 3rd type of threads which you could be using that are
    generated by the compiler when doing compiler parallelization.
    By compiling with -xparallel or -openmp=parallel, the compiler
    can automatically parallelize loops in your code and create
    threads to do this work.
    For these type of threads, the default size is 4MB. However you
    can control this behavior through the environment variable
    ${STACKSIZE}
    The ${STACKSIZE} units are in KB, so to set your compiler
    generated threads stacksize to 8MB, you would say :
    % setenv STACKSIZE 8192
    If you are using Studio 11 as your compiler, see the "OpenMP
    API User's Guide" at :
    http://docs.sun.com/app/docs/doc/819-3694?a=load
    and look at section 5.5, "Stacks and Stack Sizes"

  • Can I homeshare between home computer and work computer?

    Can I homeshare between home computer and work computer?

    Thank the music labels and movie studios.  Apple imposes this restriction due to demands from them in their effort to fight piracy.  Yes a pain but for Apple to sell all they do they have to follow some rules dictated to them.
    Simple answer, it is the way it is.
    Implement Home Sharing in iTunes so both machines can get the same libraries.

  • HT202213 My wife and I have different iTune accounts.  How do we share purchaed content between our ipads and iphones?

    My wife and I have different iTune accounts.  How do we share purchaed content between our ipads and iphones?

    iTunes- How to share music between different user accounts on a single computer
    You cannot merge two separate libraries across user accounts. Photos does not have the function of merging different Photos.library files. If you have Aperture then you can merge the two before migrating over to Photos.

  • Security-role and security-role-assignment not working in WL7.0

    Hello all..
    Some EJB components that worked fine in WebLogic 6.1 no longer work in
    WL7.0. It has to do with the security-role and security-role-assignment
    descriptor elements no longer allowing anonymous users to be included in the
    authorization for a bean.
    For example, in WL6.1 placing these items in ejb-jar.xml:
    <assembly-descriptor>
    <security-role>
    <role-name>Employees</role-name>
    </security-role>
    <method-permission>
    <role-name>Employees</role-name>
    <method>
    <ejb-name>CustomerEJB</ejb-name>
    <method-name>*</method-name>
    </method>
    </method-permission>
    and mapping WebLogic default users to this role in weblogic-ejb-jar.xml:
    <security-role-assignment>
    <role-name>Employees</role-name>
    <principal-name>guest</principal-name>
    <principal-name>system</principal-name>
    </security-role-assignment>
    worked fine for clients creating their context using a simple
    InitialContext() constructor without specifying SECURITY_PRINCIPAL or
    SECURITY_CREDENTIALS. These users were basically "guest" to WebLogic, and
    the security-role-assignment element above told WebLogic that "guest" was in
    the Employees role for purposes of this EJB archive.
    Worked in WL6.1, no longer works in WL7.0. Client receives typical
    permission exception:
    java.rmi.AccessException: Security violation: insufficient permission to
    access method 'create'
    If I explicity connect as "system" things are fine, or I can create a new
    user in the default realm in WebLogic, put a matching <principal-name>
    element in the section above, and connect as that user. Note that if I leave
    off the <security-role> section completely, or set the required role name to
    "everyone", the anonymous access works fine. Apparently the anonymous user
    is a member of "everyone" behind the scenes even though "everyone" does not
    appear in the realm list of groups or roles.
    So, my question boils down to this: Is there a "magic" username in WL7 like
    "guest" was in WL6.1 that can be mapped to the required role name, or must
    every client connection use a true weblogic-created user with appropriate
    role assignments used to map it to the required role name.
    -Greg
    P.S. Note that none of the EJB examples provided with WL used
    <security-role>..
    Check out my WebLogic 6.1 Workbook for O'Reilly EJB Third Edition
    www.amazon.com/exec/obidos/ASIN/1931822468 or www.titan-books.com

    Below are the screen shots for PFCG:

  • Diference Between Web Intelligence and Web Intelligence Rich Client?

    Hey Guys,
    Do you know the difference between Web Intelligence and Web Intelligence Rich Client?
    I was asked about that but i couldnt help. And i need to make a decision about a Web Intelligence training. I need to decide using one or another.
    Thanks
    Vegas

    Hi Vegas,
    The Webintelligence Rich Client (WRC) has all the features of the thin webintelligence client. But WRC makes use of the client processor and memory to do all post query processing while Infoview Webi sends every request to the server for processing.
    Thus you won't find any difference between the time taken to retrieve data from the database between these two clients. But there would be huge difference in performance while doing further analysis, formatting  with the data. Also you will not need connectivity to the network to do analysis and formatting using the WRC client.
    WRC client will help you to just retrieve the data on the fly and let you play around with it while you are traveling with no network connectivity.
    Thanks
    Mohanraj CP
    http://blog,mohanraj.org

  • Load-balancing and fail-over between web containers and EJB containers

    When web components and EJB components are run in different OC4J instances, can we achieve load-balancing and fail-over between web containers and EJB containers?
    null

    It looks like there is clustering, but not loadbalancing available for rmi
    from the rmi.xml configuration. The application will treat any ejbs on the
    cluster as one-to-one look-ups. Orion will go out and get the first ejb
    available on the cluster. See the docs on configuring rmi.xml (and also the
    note below).
    That is a kind-of failover, because if machine A goes down, and the
    myotherAejbs.jar are on machine B too, orion will go out and get the bean
    from machine B when it can't find machine A. But it doesn't go machine A
    then machine B for each remote instance of the bean. You could also specify
    the maximum number of instances of a bean, and as one machine gets "loaded",
    orion would go to the next available machine...but that's not really
    loadbalancing.
    That is, you can set up your web-apps with ejbs, but let all of the ejbs be
    remote="true" in the orion-application.xml file:
    <?xml version="1.0"?>
    <!DOCTYPE orion-application PUBLIC "-//Evermind//DTD J2EE Application
    runtime 1.2//EN" "http://www.orionserver.com/dtds/orion-application.dtd">
    <orion-application deployment-version="1.5.2">
    <ejb-module remote="true" path="myotherAejbs.jar" />
    <ejb-module remote="true" path="myotherBejbs.jar" />
    <ejb-module remote="true" path="myotherCejbs.jar" />
    &ltweb-module id="mysite" path="mysite.war" />
    ... other stuff ...
    </orion-application>In the rmi.xml you would define your clustering:
    <cluster host="230.0.0.1" id="123" password="123abc" port="9127"
    username="cluster-user" />
    Tag that is defined if the application is to be clustered. Used to set up
    a local multicast cluster. A username and password used for the servers to
    intercommunicate also needs to be specified.
    host - The multicast host/ip to transmit and receive cluster data on. The
    default is 230.0.0.1.
    id - The id (number) of this cluster node to identify itself with in the
    cluster. The default is based on local machine IP.
    password - The password configured for cluster access. Needs to match that
    of the other nodes in the cluster.
    port - The port to transmit and receive cluster data on. The default is
    9127.
    username - The username configured for cluster access. Needs to match that
    of the other nodes in the cluster.

  • Diff between header line and work area.

    Diff between header line and work area.

    Hi,
    These are table with header line.
    DATA: T_TABLE type table of <table_name> with header line.
    data: begin of t_table occurs 0,
                  field1 type ...
                  field2 type ...
                  field3 type ...
          end of t_table.
    <b>The result is:</b>
    <u><b>TABLE</b></u>    
    FIELD NAME  |FIELD1|FIELD2|FIELD3|  
    HEADER LINE |EE1   |EE2   |EE3   | <---- Line 5 content
               1|AA1   |AA2   |AA3   |  
               2|BB1   |BB2   |BB3   |  
               3|CC1   |CC2   |CC3   |
               4|DD1   |DD2   |DD3   |
               5|EE1   |EE2   |EE3   |
    These are table without header line.
    DATA: T_TABLE type table of <table_name>.
    DATA: T_TABLEX LIKE TABLE OF t_table.
    <b>The result is:</b>
    <u><b>TABLE</b></u>    
    FIELD NAME  |FIELD1|FIELD2|FIELD3|  
                     0|---   |---   |---   | <---- No header Line
                     1|AA1   |AA2   |AA3   |  
                     2|BB1   |BB2   |BB3   |  
                     3|CC1   |CC2   |CC3   |
                     4|DD1   |DD2   |DD3   |
                     5|EE1   |EE2   |EE3   |
    These are work areas:
    Tables <table>.
    DATA: wa type <table>.
    DATA: wa like t_table.
    DATA: wa type line of <table>.
    <b>The result is:</b>
    <u><b>WORK AREA</b></u>  
    |EE1   |EE2   |EE3   | <---- Content
    Regards.
    Marcelo Ramos

  • Difference between web server and application server

    Hi Everybody
    Could anybody expain difference between web server and application server?
    Sharad

    Hi there
    The difference I know is the application servers provides the containers for the applications to run which is not provided by the web servers.
    For example the containers can be an EJB container or JSP container etc

  • 3.     What is the difference, if any, between a Workset and a Role?

    3.     What is the difference, if any, between a Workset and a Role?

    Hai
    Pls check these links
    http://help.sap.com/saphelp_nw04s/helpdata/en/4f/bceaffeb8c114ebef8255b63079c7c/frameset.htm
    http://www2.sapdesignguild.org/resources/ma_guidelines_3/introduction/what.html
    Reward points if helpful
    Regards
    Nissy

Maybe you are looking for

  • EXCEPTION_ACCESS_VIOLATION in GetNlsSectionName??

    On WIndows XP I sometimes (about 10% of the time) get: An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x7C8189BE Function=GetNlsSectionName+0xD5D Lib

  • Customer exit variable in Report designer

    Hello, I have created one Customer Exit variable ( variable ready for input) for one of the characteristics in a query. However, when i execute this query in Report designer, the selection variable is not appearing. It is just taking the variable val

  • Error in processing caused by: com.sap.aii.af.rfc.afcommunication.RfcAFWExc

    Hello All, Does anyone know what this message means? All our programs using RFC to send data to another system is encountering error below. Please help. Error in processing caused by: com.sap.aii.af.rfc.afcommunication.RfcAFWException: alternativeSer

  • How to import/export   from d2k

    hi hi please could you help me in how to import/export from d2k. M.P.Kiran Kumar

  • Single Precision Floating Point Numbers to Bytes

    Ok here is some code that i have written w hile back with some help from the support staff. It is designed to take in precision floating point numbers that are stored as 4 bytes and convert then to a decimal value. It works off of a udp input string