2
I have a project Class Library which contains the context, configuration files and access classes to the database. His reference in an Asp.Net MVC project works normally, he accesses the data and so on, but in a project of the type Console Applicationthe context does not "load" the Connection Stringwho is in App.config, which is 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>
This App.config is in the Application Console?
– Vinícius
Yes, it’s in the same place...
– JcSaint
@Jcsaint makes the following test, force him to search for the name like this:
public SiteContext () : base("name=SiteBanco")and put what happened here in the comments.– novic
@Virgilionovic worked, thanks...
– JcSaint
@Jcsaint I left then also as reply.
– novic