Error on using Entity Framework on released winform application

236 Views Asked by At

I used entity framework V6 in win form App. I have correct connection string in App.config

but when I made setup package and install on a client machine I got this error.

"No connection string named 'MyEntities1' could be found in the application config file."
2

There are 2 best solutions below

0
On BEST ANSWER

AppConfig is originally gets created in the project that we generate the entity model. But if you are executing the application using some other project, the AppConfig needs to be included in the project which is being executed.

You can also try this example try doing the changes as mentioned below name of entities should be changed as per your ef configuration.

 public MasterEntities()
        : base("name=MyApplicationEntities")
    {
    }


to 
 public MasterEntities()
        : base("MyApplicationEntities")
    {
    }
0
On

In your startup project (Project name is in bold if you're using Visual Studio) you should have a file named App.config and the file should contain the following section:

<configuration>
   <!-- ... some other app specific configurations -->

    <connnectionStrings>
     <add name="MyEntities1" connectionString="yourConnectionString"/>
    </connectionStrings>
</configuration>