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

Read appsettings in asp net core console application

$
0
0

I'm trying to read the appsetting on my console application as well as to set he EntityFramework connection string.

I did a lot of google but did not found any single solution not even on Microsoft's documentation.

Here is the my questions.

  1. How to set the EntityFramework connection string?, my entity framework project is separate, for my MVC project I did this as below code.
string connectionString = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<MyDBContext>(option =>option.UseSqlServer(connectionString, m => m.MigrationsAssembly("MyMVCDLL")));
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
  1. How to read the appsetting?
  2. How to implement the DI in console applciation to get the appsettings?

Can someone help me with this.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>