I am trying a project on WinForms. I made a Form name Dashboard
and User Control name DashboardScreen
.
Dashboard
basically will have many User Controls on it like DashboardScreen
, InventoryScreen
, SettingsScreen
etc. These screens are small and Dock in main parent form Dashboard
so when user click on button, corresponding user control comes to the front using DashboardScreen.BringToFront()
These user controls are implementing Entity Framework V 6.4.0
User controls and Main Dashboard Form works fine when I do not use Entity Framework on these controls. Whenever I use Entity Framework as RestaurentEntities DB = new RestaurentEntities();
to utilize database services the Main Dashboard Form gives the following Error in Design Mode.
No connection string named 'RestaurentEntities' could be found in the application config file.
Second Error is
The variable 'dashboardScreen' is either undeclared or was never assigned.
Given is my configuration file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings><add name="RestaurentEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=YASIR\SQLDEVENV;initial catalog=Restaurent;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>