locked
Error with EntityConnection and Windows Workflow Activity 3.5 RRS feed

  • Question

  • Hi

    I'm trying to develop some windows workflow activities that will use the Entity Framework for calling stored precedures.

     

    However, when I compile I get the following error:
    Could not create activity of type 'InsertMeasurements'. System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.  
    at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
    at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
    at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
    at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)

    I have copied my app.config file ( that has the EF connection string to ALL of my projects ) but this has not helped.

     

    The EF connection string is in a project called Entities.SqlServer and is being called in a project called Data.Activities.

    The strange thing is I tested called the Entities.SqlServer classes from a console app, using the same app.con file - and it was fine. Its only when I compile the whole solution or only compile the Entities.SqlServer, that the Activites project has a compile error.

    Anyone have any ideas on how to fix this?

     

    Thanks

     

    Monday, August 2, 2010 11:05 AM

Answers

  • On 8/2/2010 9:32 AM, Magick93 wrote:
    > Hi
    >
    > Thanks for the reply. I must admit, I dont really understand your answer.
    >
    > This is the 3rd time I have using WF and EF together. The last time the
    > database was almost identical except that its postgresql and this time I
    > am using sql server.
    >
    > I have architected the two solutions almost identically.
    >
    > Heres an overview of my architecture:
    >
    > Entity project - contains the EF objects
    >
    > Data.SqlServer - contains Linq to EF queries, inserts etc, static classes
    >
    > Data.Activites - calls the Data.SqlServer classes from custom
    > activities. The activities are essentially wrapper classes for the
    > Data.SqlServer classes.
    >
    > TestConsole - testing of the Data.SqlServer classes
    >
    > What do you mean by object injection?
    >
     
    So why can't you have one custom (class/object) that has public
    properties and methods that call the static classes?
     
    You would inject the custom object into the Workflow as an argument into
    the WF and start the WF. The WF activities would act upon the public
    properties and methods of this custom object that in turn calls the
    methods of your static classes, which is object injection or dependency
    injection.
     
    You may have the start of it if Data.Activites is an object that can be
    instantiated, where you can inject Activities into the Workflow,.
     
     
    Monday, August 2, 2010 3:07 PM

All replies

  • On 8/2/2010 7:05 AM, Magick93 wrote:
    > Hi
    >
    > I'm trying to develop some windows workflow activities that will use the
    > Entity Framework for calling stored precedures.
    >
    > However, when I compile I get the following error:
    > Could not create activity of type 'InsertMeasurements'.
    > System.ArgumentException: The specified named connection is either not
    > found in the configuration, not intended to be used with the
    > EntityClient provider, or not valid.
    > at
    > System.Data.EntityClient.EntityConnection.ChangeConnectionString(String
    > newConnectionString)
    > at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
    > at System.Data.Objects.ObjectContext.CreateEntityConnection(String
    > connectionString)
    > at System.Data.Objects.ObjectContext..ctor(String connectionString,
    > String defaultContainerName)
    >
    > I have copied my app.config file ( that has the EF connection string to
    > ALL of my projects ) but this has not helped.
    >
    > The EF connection string is in a project called Entities.SqlServer and
    > is being called in a project called Data.Activities.
    >
    > The strange thing is I tested called the Entities.SqlServer classes from
    > a console app, using the same app.con file - and it was fine. Its only
    > when I compile the whole solution or only compile the
    > Entities.SqlServer, that the Activites project has a compile error.
    >
    > Anyone have any ideas on how to fix this?
    >
     
    I think you're going to have to have a custom object. The custom object
    has public methods that work with EF to run the sprocs. The custom
    object is injected into the Workflow using object injection. The WF
    activities act upon the public methods of the custom object that was
    injected into it.
     
    That's how I got things to work by using a custom object, which had
    other custom object graphs in it, all of it was injected into the WF,
    and the WF activities acted upon the object methods that were using the EF.
     
    The custom object was defined as an object in the WF project.
     
    The app.config with the connection string had to be defined in the
    project that's has reference to the WF project that's going to start the
    WF, as the root config file.
     
    In my case, the EF connection string was in the root Web.config when ran
    normally. However, I was doing functional testing of the WF, and the FT
    project had the app.config with the connection string for EF.
     
     
     
     
     
    Monday, August 2, 2010 1:24 PM
  • Hi

    Thanks for the reply. I must admit, I dont really understand your answer.

    This is the 3rd time I have using WF and EF together. The last time the database was almost identical except that its postgresql and this time I am using sql server. 

    I have architected the two solutions almost identically. 

     

    Heres an overview of my architecture:

    Entity project -  contains the EF objects

    Data.SqlServer - contains Linq to EF queries, inserts etc, static classes

    Data.Activites -  calls the Data.SqlServer classes from custom activities. The activities are essentially wrapper classes for the Data.SqlServer classes.

    TestConsole -  testing of the Data.SqlServer classes

     

    What do you mean by object injection?

    Monday, August 2, 2010 1:32 PM
  • On 8/2/2010 9:32 AM, Magick93 wrote:
    > Hi
    >
    > Thanks for the reply. I must admit, I dont really understand your answer.
    >
    > This is the 3rd time I have using WF and EF together. The last time the
    > database was almost identical except that its postgresql and this time I
    > am using sql server.
    >
    > I have architected the two solutions almost identically.
    >
    > Heres an overview of my architecture:
    >
    > Entity project - contains the EF objects
    >
    > Data.SqlServer - contains Linq to EF queries, inserts etc, static classes
    >
    > Data.Activites - calls the Data.SqlServer classes from custom
    > activities. The activities are essentially wrapper classes for the
    > Data.SqlServer classes.
    >
    > TestConsole - testing of the Data.SqlServer classes
    >
    > What do you mean by object injection?
    >
     
    So why can't you have one custom (class/object) that has public
    properties and methods that call the static classes?
     
    You would inject the custom object into the Workflow as an argument into
    the WF and start the WF. The WF activities would act upon the public
    properties and methods of this custom object that in turn calls the
    methods of your static classes, which is object injection or dependency
    injection.
     
    You may have the start of it if Data.Activites is an object that can be
    instantiated, where you can inject Activities into the Workflow,.
     
     
    Monday, August 2, 2010 3:07 PM
  • Well I've got it to work.

     

    I just changed the architeture. Rather than havíng a seperate project for my WF activities, I now have my activities in the WF Services project and it works fine. Not sure why it didnt before, but I would just rather get it to work.

     

    thanks for your input. It sounds like an interesting approach.

    Tuesday, August 3, 2010 6:51 AM