hi,
some times (5-10%) when i try to execute EF Query this error appear :
System.Exception: خطأ عند محاولة ملء مصدر البيانات. تم طرح الاستثناء التالي:
Failed to connect to the database. To learn more, see the exception details.
Exception details:
The default DbConfiguration instance was used by the Entity Framework before an attempt was made to set an instance of 'DbConfiguration'. The 'DbConfiguration' instance must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. ---> DevExpress.XtraReports.DataRetrievalException: خطأ عند محاولة ملء مصدر البيانات. تم طرح الاستثناء التالي:
Failed to connect to the database. To learn more, see the exception details.
Exception details:
The default DbConfiguration instance was used by the Entity Framework before an attempt was made to set an instance of 'DbConfiguration'. The 'DbConfiguration' instance must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http:
Exception details:
The default DbConfiguration instance was used by the Entity Framework before an attempt was made to set an instance of 'DbConfiguration'. The 'DbConfiguration' instance must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. ---> System.InvalidOperationException: The default DbConfiguration instance was used by the Entity Framework before an attempt was made to set an instance of 'DbConfiguration'. The 'DbConfiguration' instance must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http:
it dosn't happens with one query but different queries
What I have tried:
i can't follow this error because it Suddenly happens but i checked MySQL service and it work.
Where do I start tracking and finding a solution to this problem?
Update 1
i use this function to set custom connection parameters
public static mrsalesdbEntities OpenConn()
{
mrsalesdbEntities MrSalesContext = new mrsalesdbEntities();
MrSalesContext.Database.CommandTimeout = 999999;
MrSalesContext.ChangeDatabase
(
initialCatalog: myconn.database,
port: Convert.ToUInt32( myconn.port),
userId: myconn.uid,
password: myconn.password,
dataSource: myconn.server
);
return MrSalesContext;
}
mrsalesdbEntities DB1 = ConnectionTools.OpenConn();
Update 2
i tried to add my custom configs but also it still read the connection parameters from App.config gile
public class FE6CodeConfig : DbConfiguration
{
public FE6CodeConfig()
{
SetDefaultConnectionFactory(new LocalDbConnectionFactory(myconn.database,myconn.mrsales_Coonn));
}
}
[DbConfigurationType("MrSales.MrSModels.FE6CodeConfig, MrSales")]