C# 当前模型不再匹配用于预生成映射视图的模式

C# 当前模型不再匹配用于预生成映射视图的模式,c#,database,entity-framework,orm,entity-framework-6,C#,Database,Entity Framework,Orm,Entity Framework 6,我试图使用EF 6.1.0访问数据库中的一个表,但当我试图从数据库中的一个特定表中获取数据时,出现了一个错误。我使用ado.net项从现有数据库导入了数据库 下面是我得到错误的代码: var dbSrc = new WebInterfaceOldEntities(); List<ut_User> users = dbSrc.ut_User.ToList(); <===== error 这是我的Ut_用户类: //----------------------------

我试图使用EF 6.1.0访问数据库中的一个表,但当我试图从数据库中的一个特定表中获取数据时,出现了一个错误。我使用ado.net项从现有数据库导入了数据库

下面是我得到错误的代码:

var dbSrc = new WebInterfaceOldEntities();
List<ut_User> users = dbSrc.ut_User.ToList();    <=====  error
这是我的Ut_用户类:

//------------------------------------------------------------------------------
// <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 FillkDb
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations.Schema;

    public partial class ut_User
    {
        public int UserID { get; set; }
        public string Name { get; set; }
        public string Password { get; set; }
        public string Email { get; set; }
        public Nullable<int> AccessLevel { get; set; }
        public Nullable<int> Creator { get; set; }
        public string Company { get; set; }
        public string PhoneWork { get; set; }
        public string PhoneHome { get; set; }
        public string Cell { get; set; }
        public string AddressStreet1 { get; set; }
        public string AddressStreet2 { get; set; }
        public string AddressStreet3 { get; set; }
        public string AddressPostCode { get; set; }
        public System.Guid msrepl_tran_version { get; set; }
    }
}
//------------------------------------------------------------------------------
// 
//此代码是从模板生成的。
//
//手动更改此文件可能会导致应用程序出现意外行为。
//如果重新生成代码,将覆盖对此文件的手动更改。
// 
//------------------------------------------------------------------------------
命名空间填充KDB
{
使用制度;
使用System.Collections.Generic;
使用System.ComponentModel.DataAnnotations.Schema;
公共部分类ut_用户
{
public int UserID{get;set;}
公共字符串名称{get;set;}
公共字符串密码{get;set;}
公共字符串电子邮件{get;set;}
公共可空访问级别{get;set;}
公共可为空的创建者{get;set;}
公共字符串公司{get;set;}
公共字符串电话工作{get;set;}
公共字符串PhoneHome{get;set;}
公共字符串单元格{get;set;}
公共字符串地址street1{get;set;}
公共字符串地址street2{get;set;}
公共字符串地址street3{get;set;}
公共字符串地址邮政编码{get;set;}
public System.Guid msrepl_tran_version{get;set;}
}
}
以下是上下文:

using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class WebInterfaceOldEntities : DbContext
{
    public WebInterfaceOldEntities()
        : base("name=WebInterfaceOldEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }    

    public virtual DbSet<ut_User> ut_User { get; set; }
    ...   
}
使用系统;
使用System.Data.Entity;
使用System.Data.Entity.Infrastructure;
公共部分类WebInterfaceDentities:DbContext
{
公共网络接口身份()
:base(“名称=WebInterfaceDentities”)
{
}
模型创建时受保护的覆盖无效(DbModelBuilder modelBuilder)
{
抛出新代码FirstException();
}    
公共虚拟数据库集ut_用户{get;set;}
...   
}

错误是说自动生成的模型不再与数据库架构匹配-数据库或模型在生成后是否发生了更改?它说是的,但在我导入数据库后立即这样说。所以它肯定没有改变。
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class WebInterfaceOldEntities : DbContext
{
    public WebInterfaceOldEntities()
        : base("name=WebInterfaceOldEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }    

    public virtual DbSet<ut_User> ut_User { get; set; }
    ...   
}