✅ 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
Zelort
Zelort2d ago
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;
Pobiega
Pobiega2d ago
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
Unknown User2d 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
Unknown User2d ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?