0
legion123 created
i use EntityFramework and Module-Zero example
i hope this class
[Table("Tasks")]
public class Task : Entity<long>
{
public Task()
{
}
public virtual string taskName { get; set; }
// module-zero user class EF automatic link
public virtual User usr { get; set; }
[ForeignKey("UserId")]
public virtual long? UserId { get; set; }
}
but An Error occured [The property 'UserId' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection<T> where T is a valid entity type.]
what can i do ? thank you.
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)
2 Answer(s)
-
0
That's related to EF. Use [ForeignKey("UserId")] for User property, not UserId. Also I suggest to rename usr to User.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
thank you. i will try it.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)