Skip to content

Instantly share code, notes, and snippets.

View ibrahimozgon's full-sized avatar

ibrahim özgön ibrahimozgon

View GitHub Profile
public class MyDbContext : DbContext
{
private readonly ILoggerFactory _loggerFactory;
public MyDbContext(DbContextOptions<MyDbContext> options, ILoggerFactory loggerFactory) : base(options)
{
_loggerFactory = loggerFactory;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
[Route("api/[controller]")]
[ApiController]
public class ProductsController : ControllerBase
{
private readonly MyDbContext _context;
public ProductsController(MyDbContext context)
{
_context = context;
}
// GET api/values
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
//1
//services.AddDbContext<MyDbContext>(options => { options.UseInMemoryDatabase(Guid.NewGuid().ToString()); });
services.AddDbContext<MyDbContext>(options =>
{
options.UseSqlServer(@"Server=localhost\SQLEXPRESS;Database=ODataTest;Trusted_Connection=True;");
});
//2
@ibrahimozgon
ibrahimozgon / conf
Last active December 14, 2017 18:40
Nginx Elasticsearch Configuration Files
proxy_cache_path /var/cache/nginx/cache keys_zone=elasticsearch:10m inactive=60m;
upstream elasticsearch_servers {
least_conn;
server 47.4.119.33 weight=1;
server 159.173.202.86 weight=1;
server 121.161.211.146 weight=1;
server 119.112.63.63 weight=1;
server 249.165.150.187 weight=1;
}