title: Repositories in .net core library
body: <p>I'm trying to wrap basic actions fro model(like get by id, etc.) in repositories. However I'm facing with two problems:</p>
  
  <p><strong>1. Connection String</strong> : Is there any solution to put it in config, and not to hard code it in class, like I did?</p>
  
  <pre><code> public const string ConnectionString = "Server = (localdb)\\mssqllocaldb;Database=pinchdb;Trusted_Connection=True;MultipleActiveResultSets=true";// can I get rid of it?
      public DbSet&lt;Department&gt; Departments { get; set; }
      public DbSet&lt;Employee&gt; Employees { get; set; }
      public DbSet&lt;Project&gt; Projects { get; set; }
      public DbSet&lt;ProjectDepartments&gt; ProjectsDepartments { get; set; }
      public DbSet&lt;Roles&gt; Roles { get; set; }
      public effMercContext(DbContextOptions&lt;effMercContext&gt; options)
          : base(options)
      {
      }
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;ProjectDepartments&gt;()
              .HasKey(t =&gt; new { t.ProjectId, t.DepartmentId });
          modelBuilder.Entity&lt;ProjectDepartments&gt;()
              .HasOne(pt =&gt; pt.Project)
              .WithMany(p =&gt; p.ProjectDepartment)
              .HasForeignKey(pt =&gt; pt.ProjectId);
          modelBuilder.Entity&lt;ProjectDepartments&gt;()
              .HasOne(pt =&gt; pt.Department)
              .WithMany(t =&gt; t.ProjectDepartment)
              .HasForeignKey(pt =&gt; pt.DepartmentId);
      }
  }
  public class EffMercDbContextFactory : IDbContextFactory&lt;effMercContext&gt;
  {
      public effMercContext Create(DbContextFactoryOptions options)
      {
          var builder = new DbContextOptionsBuilder&lt;effMercContext&gt;();
          builder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=pinchdb;Trusted_Connection=True;MultipleActiveResultSets=true");
          return new effMercContext(builder.Options);
      }
  }
  </code></pre>
  
  <p><strong>2. Can I call Dbcontext without options to implement methods?</strong></p>
  
  <pre><code>      public Employee GetByID(int id)
      {
          var optionsBuilder = new DbContextOptionsBuilder&lt;effMercContext&gt;();// how can I get rid of this and just call effMercContext
          optionsBuilder.UseSqlServer(effMercContext.ConnectionString);
          using (effMercContext db = new effMercContext(optionsBuilder.Options))
          {
              return db.Employees.Where(x =&gt; x.Id == id).FirstOrDefault();
          }
      }
  </code></pre>