Add EF Core and RecDbContext for database integration
Added the `Microsoft.EntityFrameworkCore` NuGet package to the `ReC.Infrastructure` project to enable database functionality. Introduced `RecDbContext` with `DbSet` properties for `EndpointParam`, `Action`, and `OutRes` entities. Configured `Action` as a keyless entity in `OnModelCreating`. Added a project reference to `ReC.Domain` to use domain entities in the infrastructure layer.
This commit is contained in:
parent
b94a620389
commit
163b5bc2f9
@ -6,4 +6,12 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ReC.Domain\ReC.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
20
src/ReC.Infrastructure/RecDbContext.cs
Normal file
20
src/ReC.Infrastructure/RecDbContext.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Infrastructure;
|
||||
|
||||
public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<EndpointParam> EndpointParams { get; set; }
|
||||
|
||||
public DbSet<Domain.Entities.Action> Actions { get; set; }
|
||||
|
||||
public DbSet<OutRes> OutRes { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Domain.Entities.Action>().HasNoKey();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user