https://github.com/itsyst/library-management-system
Migrate from ASP.NET Core 3.1 to 8.0 achieved by: Eric Van Dan Outenaar, and Khaled El Hamzi.
https://github.com/itsyst/library-management-system
asp-net-core bootstrap5 clean-architecture csharp entity-framework-core net7 razor-pages sql
Last synced: 7 months ago
JSON representation
Migrate from ASP.NET Core 3.1 to 8.0 achieved by: Eric Van Dan Outenaar, and Khaled El Hamzi.
- Host: GitHub
- URL: https://github.com/itsyst/library-management-system
- Owner: itsyst
- License: mit
- Created: 2020-10-16T09:23:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-31T12:42:11.000Z (over 1 year ago)
- Last Synced: 2024-01-31T13:47:23.459Z (over 1 year ago)
- Topics: asp-net-core, bootstrap5, clean-architecture, csharp, entity-framework-core, net7, razor-pages, sql
- Language: C#
- Homepage: https://library.elhamzi.com
- Size: 7.4 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Library-Management-System
This Project is an open-source project updated from Asp.Net 3.1 to .NET Core 8.
## Give a Star! :star:
If you Like the project, please give a star ;)
## How to use:
- You will need the latest Visual Studio 2022 and the latest .NET Core 8.
- The latest SDK and tools can be downloaded from https://dot.net/core.
Also you can run this Project in Visual Studio Code (Windows, Linux or MacOS).
To know more about how to setup your enviroment visit the [Microsoft .NET Download Guide](https://www.microsoft.com/net/download)
Build a complete e-commerce application ASP.NET Core MVC .NET 8## Here is a quick check list you could follow to migrate your application from .Net 3.1 to .Net 6
- Upgrade the reference in csproj files
```
// Old
netcoreapp3.1
// New
net6.0
enable
enable
````
- Upgrade the packages````
//Old
all
runtime; build; native; contentfiles; analyzers; buildtransitive
// New
---
all
runtime; build; native; contentfiles; analyzers; buildtransitive
````
- Upgrade the namespaces
```
//Old
namespace Library.Domain
{
public class Author
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public IList? Books { get; set; }
}
}// New
namespace Library.Domain;
public class Author
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public IList? Books { get; set; }
}
````- Migrate startup class to Program.cs
```
//Old StartUp class
using Library.Application.Interfaces;
using Library.Infrastructure.Persistence;
using Library.Infrastructure.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;namespace Library.MVC
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
// Here we inject our services into the the DI container
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();// This call injects our applicationDbContext (our implementation of Entity Framework Core)
services.AddDbContext(options =>
options.UseSqlServer(Configuration.GetConnectionString("LibrarySystem"),
x => x.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName)
));
}// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}//New Programm class
using Library.Application.Interfaces;
using Library.Infrastructure.Services;
var builder = WebApplication.CreateBuilder(args);// Add services to the container.
builder.Services.AddControllersWithViews();//DbContext configuration
builder.Services.AddDbContext(options => options.UseSqlServer(
builder.Configuration.GetConnectionString("LibrarySystem"),
b => b.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName))
);//Services configuration
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}app.UseAuthentication();
app.UseStaticFiles();app.UseRouting();
app.MapRazorPages();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});app.Run();
```- Delete the old bin and obj folders
- Build your application🚀 Ready to go