Test EF / Mysql

This commit is contained in:
2018-10-05 00:18:37 +02:00
parent 5a690e4dbe
commit d2c1a9d5f9
7 changed files with 76 additions and 3 deletions

View File

@@ -2,14 +2,18 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LaDOSE.Api.Context;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Pomelo.EntityFrameworkCore.MySql;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
namespace LaDOSE.Api
{
@@ -26,7 +30,16 @@ namespace LaDOSE.Api
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddDbContextPool<LaDOSEDbContext>( // replace "YourDbContext" with the class name of your DbContext
options => options.UseMySql("Server=localhost;Database=ladose;User=root;Password=;", // replace with your Connection String
mysqlOptions =>
{
mysqlOptions.ServerVersion(new Version(10, 1, 16), ServerType.MariaDb); // replace with your Server Version and Type
}
));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)