✅ ASP.NET Core Web API Model Creation.
I have complete the restfull api know i want to know how can i create Foreign key, on cascade delete, set varchar(100) and many more
5 Replies
just add
[ForeignKey]
attribute in your field in model class,
"varchar(100) " you can use this StringLength attribute:
[StringLength(100)]
public string Description { get; set; } = string.Empty;
Assuming you are using EF Core: https://learn.microsoft.com/en-us/ef/core/modeling/
Avoid using the attributes if possible, prefer
IEntityConfiguratiion<TEntity>
or at the very least do it in OnModelCreating
Unknown User•2d ago
Message Not Public
Sign In & Join Server To View
Ok
How can i response as a JSON {"message":"Login Successfull"} in return Ok() or NotFound()
Unknown User•2d ago
Message Not Public
Sign In & Join Server To View