有一些MVC应用程序的代码是在.NET 4.5框架下使用VS 2012构建的。但是我的系统要求我在VS 2010上工作。我设法在我的VS 2010中打开了VS 2012解决方案,但问题是VS 2010仅支持.NET 4。
代码中有一些函数使用只适用于.NET 4.5的dll文件,例如 System.ComponentModel.DataAnnotations.Schema
。
因此,在.NET 4中是否有可用于执行与.NET 4.5相同操作的替代函数/属性?
这是我当前使用.NET 4.5的代码:
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
}
如您所见,DatabaseGeneratedAttribute
可在 System.ComponentModel.DataAnnotations.Schema
命名空间下找到,这是 .NET 4.5 的一部分。
请问,在 .NET 4 中有哪些对应的函数/属性可以表示相同的逻辑呢?
注意:在上面给出的代码片段中,我遇到了 Table
和 DatabaseGeneratedAttribute
的错误提示:
无法找到类型或命名空间名称 'Table'(是否缺少 using 指令或程序集引用?)
以及
无法找到类型或命名空间名称 'DatabaseGeneratedAttributeAttribute'(是否缺少 using 指令或程序集引用?)
因此,我猜想只需要在 NET 4.0 中找到相应的类即可解决问题。非常感谢您的帮助。
Assembly EntityFramework -D:\Programming\MVC\PassMe\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll
。 - SwayamSystem.ComponentModel.DataAnnotations.Schema
。 - Srikanth Venugopalan