Unable to save roles RRS feed

  • Question

  • Hello,

    I have a small LS test app, and when I try to save a Role with some Permissions I get an error saying:

    Unable to save data - Entity host is not initialized.

    I can save any other information in my application normally, this only happens with Roles. This happens using Forms authentication or Windows authentication. Any idea or tip on what is happening there?


    Vicente Cartas Espinel - MVP XNA/DirectX

    Twitter - VicenteCartas

    Blog about C# and XNA Development

    Blog about Role Playing Games

    Tuesday, November 1, 2011 2:43 PM


All replies

  • Can you post a sample of code that reproduces this error or does this happen through the Roles screen itself?
    Tuesday, November 1, 2011 4:07 PM
  • Same problem here. I converted a perfectly working LightSwitch application (which had Windows Authentication) to Forms Authentication. After deployed, the Forms Authentication application won't save roles, saying the error message "Unabel to save data: Entity host is not initialized." I suspect it's something to do with the sharing of the database between WinAuthApp and FormsAuthApp.

    Can't attach any code here since I don't know which part is having a problem unless I upload the whole project. It's just from the default Role management page. I couldn't find any info about this error message from web. This is the only posting a Search Engine comes up with this error message.

    • Edited by RiverWay Friday, November 4, 2011 7:08 PM
    Friday, November 4, 2011 7:06 PM
  • Can you add the new role first (save). Then add permissions after?
    Friday, November 4, 2011 7:24 PM
  • I have tried to build a repro, but no luck. But while trying to build a repro, not sure how, the problem disappeared. I did the following.

    Copied the folder of the app to somewhere (everything). Opened the copy solution, took out all the screens and entities, clean and build. Then not sure why, I could save roles.

    Then I went to my original application (nothing changed there), and it could save roles too :S I have no clue what has happened here...

    Vicente Cartas Espinel - MVP XNA/DirectX

    Twitter - VicenteCartas

    Blog about C# and XNA Development

    Blog about Role Playing Games

    Friday, November 4, 2011 8:03 PM
  • That seemed to work! But after saving permissions, it gives error saying there are duplicated permissions. And later after refreshing everything looked OK. Thanks guys. 
    Friday, November 4, 2011 8:10 PM
  • Hi guys. 

    How can this be marked as an answer? It does not resolve the issue.

    Thursday, March 20, 2014 10:47 AM
  • I had to fight with this issue myself: here's the complete breakdown of what I had to do to solve the problem:

    1) Three-tier setup, with a SL client for permissions and an HTML5 client for the application, VS2013, hosted in IIS.

    2) The service worked in development, but not production.  I ruled out a deployment issue, because adding Roles and manipulating Users was fine.

    3) Bouncing the web app on IIS did not resolve the issue.

    4) Installed remote debugger on deployment machine, and attached VS debugger.

    5) SQL error complaining about a foreign key constraint was found... the SL client was not retrieving the already existing permissions somehow, and then even on loading the page, was trying to run an update statement for some reason.

    6) Basically cleared out all permissions from the roles_permissions table (luckily I only have a few) save for the Administrator ones.

    7) Re-added permissions to roles.

    8) Silverlight client now properly adds and removes permissions from roles.

    I am still at a loss for what happened.  Here's the actual sequence from a human perspective:

    1) Deployed application

    2) User reported problem setting up permissions

    3) Debugged and saw the low level SQL errors in System.Data.Client

    4) Checked the table, and saw the permissions I was trying to add were already there, but they weren't in the UI.

    I am unsure what the root cause is, but somehow my client was not picking up the proper permission records, then trying to insert them, causing Duplicate Key errors.  This is erroneously reported upstream in the client as "Unable to save data - Entity host is not initialized."

    Thursday, May 22, 2014 3:52 PM
  • Dear All,

    I had the same problem, after many tries I found that that you have to:

    1- Delete the old role name

    2- Save

    3- Create a new role name (IMPORTANT the new role name should not be the same as the old role name, example if the old one is London the new one should be London1)

    4- Save 

    :) Hope it will help

    Best regards,


    Wednesday, November 12, 2014 8:09 AM