I have a Class Library
project that contains the context, configuration files, and database access classes. Its reference in an Asp.Net MVC project works normally, it accesses the data and etc, but in a project of type Console Application
the context does not "load" the Connection String
which is in App.config
, being it the same as Web.config
.
Context class:
public class SiteContext : DbContext
{
public SiteContext () : base("SiteBanco")
{
Configuration.LazyLoadingEnabled = false;
Configuration.AutoDetectChangesEnabled = false;
}
}
Web.config
and App.config
<connectionStrings> <add name="SiteBanco" connectionString="Data Source=SERVER-TEST\SQLSERVER;Initial Catalog=BaseTeste;Integrated Security=False;User ID=***;Password=*****;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" providerName="System.Data.SqlClient" /> </connectionStrings>