Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Need Get URL application

$
0
0

Hi.. I am developing in .Net Core 1.1 and need to get the URL in Startup.cs

public void ConfigureServices(IServiceCollection services)       {           string Need_Url_here = ????           //services.AddDbContext<SmartContext>(opt => opt.UseSqlServer(connectionstring));           services.AddDbContext<SmartContext>(Need_Url_here);           // Add framework services.           services.AddMvc();       }

And pass it to the DBContext.For choose which database to connect ...

public class SmartContext : DbContext  {         public SmartContext(DbContextOptions<SmartContext> opt) : base(opt)      {                }            public DbSet<BusinessEntity> BusinessEntity { getset; }
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder )        {                     string conection = config["Data:"+ Need_Url_here+ ":ConnectionString"];          // define the database to use          optionsBuilder.UseSqlServer(conection);        }

Can someone help me ?


Viewing all articles
Browse latest Browse all 9386

Trending Articles