chore: ef In-Memory-Datenbank hinzugefügt und Dienst hinzugefügt

This commit is contained in:
Developer 02 2025-01-30 00:09:02 +01:00
parent 67a4e91a1b
commit aeb1c4a810
2 changed files with 5 additions and 0 deletions

View File

@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

View File

@ -1,6 +1,8 @@
using DigitalData.Swagger.MockAPI.Data;
using DigitalData.Swagger.MockAPI.Dtos;
using DigitalData.Swagger.MockAPI.Repos;
using Microsoft.AspNetCore.OData;
using Microsoft.EntityFrameworkCore;
using Microsoft.OData.ModelBuilder;
var builder = WebApplication.CreateBuilder(args);
@ -12,6 +14,8 @@ builder.Services.AddSingleton<ICompanyRepo, CompanyRepo>();
ODataConventionModelBuilder oDataModelbuilder = new();
oDataModelbuilder.EntitySet<Company>("Companies");
builder.Services.AddDbContext<ApiContext>(opt => opt.UseInMemoryDatabase(databaseName: "CompaniesDB"));
builder.Services.AddControllers()
.AddOData(options => options
.AddRouteComponents("odata", oDataModelbuilder.GetEdmModel())