首页 > 解决方案 > Asp.net:命名空间“DataManager”中不存在类型或命名空间名称“Entity”(您是否缺少程序集引用?)

问题描述

我在 API 项目中添加了一个类库以从数据库中获取数据。在类库“DataManager”中,我创建了一个名为“Entity”的文件夹,并为 sql 和 oracle db 添加了 ADO 实体数据模型。当我为 oracle 创建 ADO 时,我不得不将实体框架版本从 6 降级到 5。

模型.Context.cs

namespace DataManger.Entity
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    
    public partial class myEntities : DbContext
    {
        public myEntities()
            : base("name=myEntities")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
    
        public DbSet<Application> Applications { get; set; }

现在,当我尝试在“实体”中获取任何模型时。

using DataManager.Entity;
using System;
using System.Collections.Generic;
using System.Linq;

namespace DataManager.Services
{
    public class ApplicationDataService : IApplicationDataService
    {

使用 DataManager.Entity 时,我在第一行收到以下错误消息

严重性代码描述项目文件行抑制状态错误 CS0234 名称空间“DataManager”中不存在类型或名称空间名称“Entity”(您是否缺少程序集引用?) D​​ataManger ......

标签: c#asp.netentity-frameworkasp.net-web-apiado.net

解决方案


推荐阅读