【发布时间】:2016-02-17 13:58:23
【问题描述】:
除了我的 Web 应用程序项目之外,我的解决方案中还有一个 BLL 和 DAL 项目。我正在使用实体框架 5,并且在 DAL 项目中有 .tt 文件。一切正常,但后来我尝试根据this 链接将 .tt 文件分离到一个新项目“实体”中。
实体和 DAL 项目构建良好。但是对于我的 BLL 中具有“使用 DAL”的所有类,我有一个新错误“找不到类型或命名空间 DAL”。我尝试清理所有解决方案并按顺序重建它们,我还尝试从 BLL 项目中删除 DAL 引用并读取它,但仍然是相同的错误。
什么可能导致这个问题?我还可以添加哪些信息来帮助找出问题所在?
编辑:
这是一个生成的 POCO 类的示例
//------------------------------------------------------------------------------
// <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 Entities
{
using System;
using System.Collections.Generic;
public partial class tblsource_type
{
public tblsource_type()
{
this.tbltitles = new HashSet<tbltitle>();
}
public int Source_Type_Id { get; set; }
public string Source_Type_Name { get; set; }
public virtual ICollection<tbltitle> tbltitles { get; set; }
}
}
【问题讨论】:
-
你检查过构建顺序和依赖关系吗?这些类是否已生成并成为 DAL 项目的一部分?
-
你能告诉我们你的 DAL dll 的类是什么样的吗?包括命名空间
-
您确定新项目使用相同的 .NET 版本了吗?
-
@Jaster 是的,我确保我以正确的顺序构建它们。 POCO 类生成良好,我从 DAL edms 中引用了新的 tt 文件
-
那么您需要
using DAL;代码吗?您的 TT 是否在该命名空间下生成 POCO 类?我们可以看到生成的类代码吗?
标签: c# entity-framework assembly-references