Skip to content

Commit cde883f

Browse files
committed
Add repro for #1224
1 parent 008bc00 commit cde883f

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/Examples/JsonApiDotNetCoreExample/Data/AppDbContext.cs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace JsonApiDotNetCoreExample.Data;
1010
public sealed class AppDbContext : DbContext
1111
{
1212
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
13+
public DbSet<PostIt> PostIts => Set<PostIt>();
1314

1415
public AppDbContext(DbContextOptions<AppDbContext> options)
1516
: base(options)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using JsonApiDotNetCore.Resources;
3+
using JsonApiDotNetCore.Resources.Annotations;
4+
5+
namespace JsonApiDotNetCoreExample.Models;
6+
7+
[Resource]
8+
public class PostIt : Identifiable<int>
9+
{
10+
[Attr]
11+
[Required]
12+
public bool Actif { get; set; }
13+
14+
[Attr]
15+
[Required]
16+
public DateTime Date { get; set; }
17+
18+
[Attr]
19+
[MaxLength(2, ErrorMessage = "Error")]
20+
public string Message { get; set; }
21+
22+
[Attr]
23+
[Required]
24+
public string RefOperateur { get; set; }
25+
}

src/Examples/JsonApiDotNetCoreExample/Program.cs

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using JsonApiDotNetCore.Configuration;
44
using JsonApiDotNetCore.Diagnostics;
55
using JsonApiDotNetCoreExample.Data;
6+
using JsonApiDotNetCoreExample.Models;
67
using Microsoft.AspNetCore.Authentication;
78
using Microsoft.EntityFrameworkCore;
89
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -98,5 +99,20 @@ static async Task CreateDatabaseAsync(IServiceProvider serviceProvider)
9899
await using AsyncServiceScope scope = serviceProvider.CreateAsyncScope();
99100

100101
var dbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
102+
103+
await dbContext.Database.EnsureDeletedAsync();
101104
await dbContext.Database.EnsureCreatedAsync();
105+
106+
var postIt = new PostIt
107+
{
108+
Id = 835405,
109+
Actif = true,
110+
Date = DateTime.UtcNow,
111+
Message = "ab",
112+
RefOperateur = "some-ref"
113+
};
114+
115+
dbContext.PostIts.Add(postIt);
116+
117+
await dbContext.SaveChangesAsync();
102118
}

0 commit comments

Comments
 (0)