“entityframework.models.foreig ... [英] 'entityframework.models.foreig...

查看:43
本文介绍了“entityframework.models.foreig ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个WPF的应用程序,它将使用实体框架CRUD操作,但我陷入了一行代码而无法继续。在其中一个类中有一个红色下划线[Foreignkey(DepId)]带有错误消息'entityframework.models.foreignkeyAttribute'不包含带有一个参数的构造函数下面是整个代码



命名空间EntityFramework.Models

{

班级员工

{

public int id {get;组; }



public string FirstName {get;组; } $ / $


public string LastName {get;组; }



公共字符串BirthDay {get;组; }



public string DepId {get;组; }



[外键(DepId)]

公共虚拟部门部门{get;组; }

}

}



请提前帮助谢谢

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

推荐答案

你应该添加System.ComponentModel.DataAnnotations命名空间。



参见这个提示...... [ ^ ]
You should add the System.ComponentModel.DataAnnotations namespace.

See this tip...[^]


这篇关于“entityframework.models.foreig ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆