'Getting these two errors when I delete a project and system.DateTime error

I need help with this issue. I am trying to delete a contract from my web application but when I delete it I get this error I used ASP.NET MVC 5 to design this web application:

enter image description here

I keep getting this error for System.DateTime:

enter image description here



Solution 1:[1]

I need more information on the first error, it looks like you're deleting something that is referenced to another table so it will have a foreign key constraint. The references of the item you are deleting will need to be removed from the other tables first.

2nd issue you need to a System.DateTime to a string, so you can do:

db.Entry(hR).Entity.ModifiedDate = LoginInfo.CurrentDate().ToString();

a better way of doing date time:

DateTime localDateTime = DateTime.Now; - local time
DateTime utcDateTime = DateTime.UtcNow; - utc time

Then add your ToString();

You can also format DateTime depending on what you are after: DateTime

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JuanR