我正在尝试使用EF 6.1.0访问数据库中的表但是当我尝试从数据库中的某个特定表中获取数据时,我收到错误。我使用ado.net项从已存在的数据库导入数据库。
以下是我收到错误的代码:
var dbSrc = new WebInterfaceOldEntities();
List<ut_User> users = dbSrc.ut_User.ToList(); <===== error
以下是错误:
The current model no longer matches the model used to pre-generate the mapping views, as indicated by the ViewsForBaseEntitySets879d00ec20bbbe0601fa7418ff0a96685f5823797e74e2cf3e6f22fdb0b43cc9.MappingHashValue property. Pre-generated mapping views must be either regenerated using the current model or removed if mapping views generated at runtime should be used instead. See http://go.microsoft.com/fwlink/?LinkId=318050 for more information on Entity Framework mapping views.
这是我的Ut_User类:
//------------------------------------------------------------------------------
// <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; }
}
}
以下是上下文:
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; }
...
}