Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing an app in WPF that is going to make use of entity framework CRUD operations, but am stuck at a line of code and could not proceed. in one of the classes there is a red underline on "[Foreignkey("DepId")]" with an error message "'entityframework.models.foreignkeyAttribute' does not contain a constructor that takes one argument" below is the whole code

namespace EntityFramework.Models
{
class Employee
{
public int id { get; set; }

public string FirstName { get; set; }

public string LastName { get; set; }

public string BirthDay { get; set; }

public string DepId { get; set; }

[Foreignkey("DepId")]
public virtual Departments Departments { get; set; }
}
}

Kindly help thank you in advance
Posted

1 solution

You should add the System.ComponentModel.DataAnnotations namespace.

See this tip...[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900