【发布时间】:2017-05-01 09:06:42
【问题描述】:
我正在使用 .net 4.5.50938 Visual Studio Community 2013 V12.0.31101.00 更新4 操作系统:赢 7 我正在尝试将我现有的网站从 VS2012 复制到 VS2013 中的项目/解决方案
使用 Visual Studio,我在“模型”文件夹中创建了一个来自数据库的实体模型,其中部分“EntityClass1”类作为其类之一。 现在我转到“App_Code”文件夹并添加一个名为“EntityClass1”的类,并添加与“EntityClass1”使用关键字相同的命名空间。但与 Visual Studio 2012 不同,我无法访问 EntityClass1 的属性!
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MyProjectToVs2013.Models
{
using System;
using System.Collections.Generic;
public partial class EntityClass1
{
public System.Guid ID { get; set; }
public string Title { get; set; }
public System.Guid Class1ID { get; set; }
public virtual Entity34 Entity34 { get; set; }
}
}
在另一个EntityClass1中:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyProjectToVs2013.Models;
using System.ComponentModel.DataAnnotations;
namespace MyProjectToVs2013.Models
{
public partial class EntityClass1
{
public EntityClass1()
{
//TODO: Add constructor logic here
}
public void createEntityClass1()
{
//here I am trying to access the properties and unlike VS2012
I cannot!! there is no such properties available via intelliSense:
Title // not appearing!
}
}
}
【问题讨论】:
-
createEntityClass1在部分类之外。这根本无效。你不能在命名空间中有方法。 -
感谢您的回复,实际上这是一个错字,我对其进行了编辑。问题依然存在。
-
迁移成功了吗?是否包含
csproj文件? .检查是否包含所有cs文件。你也应该打开sln文件。 -
您的代码对我来说很好用。 rextester.com/OZOO59727
-
@M.kazemAkhgary 正如我所提到的,我正在从网站项目迁移到解决方案项目,因此除了新创建的文件之外,没有要包含的 csproj 文件。
标签: c# .net visual-studio-2013 entity-framework-4