michel4liu / EntityFrameworkCore.SqlProfile

sqlite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install NuGet package

PM> Install-Package EntityFrameworkCore.SqlProfile

Edit Startup.cs

Insert code options.UseSqlProfile(); and routes.MapSqlProfile(); and required using directive into Startup.cs as follows.

using EntityFrameworkCore.SqlProfile; // Add
....
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddDbContext<SqliteDbContext>(options =>
    {
        options.UseSqlite(Configuration.GetConnectionString("Sqlite"));
        options.UseSqlProfile(); // Add when use Sqlite
    });
    ....
    services.AddDbContext<SqlServerDbContext>(options =>
    {
        options.UseSqlServer(Configuration.GetConnectionString("SqlServer"));
        options.UseSqlProfile(); // Add when use SqlServer
    });
    ....
}
....
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseMvc(routes =>
    {
        routes.MapSqlProfile(); // Add
	....
    });
}

View SQL via Browser

Eg. input https://localhost:44393/logger

screenshot

Technologies

My projects

About

sqlite

License:MIT License


Languages

Language:C# 99.6%Language:TSQL 0.4%