我正在为我创建的现有数据库使用EntityFramework。 我使用基于模型的视图使用了一个视图,并且在删除自己的模型页面视图后出现错误。 再次使用生成视图创建EntityFramework,我收到这样的错误
错误
运行所选代码生成器
时出错异常抛出了调用的目标
以前的版本运行良好。
使用appsettings
连接数据库后,创建模型。创建自己的视图获取错误删除我自己的视图文件。
再次使用EntityFramework我得到的错误就像这样。
代码:
<connectionStrings>
<add name="tickandtieEntities" connectionString="metadata=res://*/Entityframework.Tickmarks.csdl|res://*/Entityframework.Tickmarks.ssdl|res://*/Entityframework.Tickmarks.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-QD6A981\SQLEXPRESS;initial catalog=tickandtie;user id=sa;password=root;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
namespace Inspinia_MVC5.Entityframework
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Core.Objects;
using System.Linq;
public partial class tickandtieEntities : DbContext
{
public tickandtieEntities()
: base("name=tickandtieEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Role> Roles { get; set; }
public virtual DbSet<TP_EBITDA> TP_EBITDA { get; set; }
public virtual DbSet<TP_EBITDA_Ratio> TP_EBITDA_Ratio { get; set; }
public virtual DbSet<TP_InternalClients> TP_InternalClients { get; set; }
public virtual DbSet<TP_Profile> TP_Profile { get; set; }
public virtual DbSet<TP_ProjectFiles> TP_ProjectFiles { get; set; }
public virtual DbSet<TP_Projects> TP_Projects { get; set; }
public virtual DbSet<TP_ReportType> TP_ReportType { get; set; }
public virtual DbSet<TP_Roles> TP_Roles { get; set; }
public virtual DbSet<TP_Users> TP_Users { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<TP_Chatter> TP_Chatter { get; set; }
public virtual ObjectResult<AddChatter_Result> AddChatter(Nullable<int> projectId, Nullable<int> userId, string userName, string content)
{
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
var userIdParameter = userId.HasValue ?
new ObjectParameter("UserId", userId) :
new ObjectParameter("UserId", typeof(int));
var userNameParameter = userName != null ?
new ObjectParameter("UserName", userName) :
new ObjectParameter("UserName", typeof(string));
var contentParameter = content != null ?
new ObjectParameter("Content", content) :
new ObjectParameter("Content", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<AddChatter_Result>("AddChatter", projectIdParameter, userIdParameter, userNameParameter, contentParameter);
}
public virtual ObjectResult<EventReport_Result> EventReport()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<EventReport_Result>("EventReport");
}
public virtual ObjectResult<ExpenseReport_Result> ExpenseReport()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ExpenseReport_Result>("ExpenseReport");
}
public virtual ObjectResult<GetChatterList_Result> GetChatterList(Nullable<int> projectId)
{
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetChatterList_Result>("GetChatterList", projectIdParameter);
}
public virtual ObjectResult<GetClientsDetail_Result> GetClientsDetail(Nullable<bool> clientId)
{
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(bool));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetClientsDetail_Result>("GetClientsDetail", clientIdParameter);
}
public virtual ObjectResult<GetEbitDaList_Result> GetEbitDaList()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetEbitDaList_Result>("GetEbitDaList");
}
public virtual ObjectResult<GetEbitDaRatioList_Result> GetEbitDaRatioList()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetEbitDaRatioList_Result>("GetEbitDaRatioList");
}
public virtual ObjectResult<GetEmployeeList_Result> GetEmployeeList(Nullable<bool> clientId)
{
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(bool));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetEmployeeList_Result>("GetEmployeeList", clientIdParameter);
}
public virtual ObjectResult<GetProjectDetail_Result> GetProjectDetail(Nullable<int> projectId)
{
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetProjectDetail_Result>("GetProjectDetail", projectIdParameter);
}
public virtual ObjectResult<GetUserProfile_Result> GetUserProfile(Nullable<int> uid)
{
var uidParameter = uid.HasValue ?
new ObjectParameter("uid", uid) :
new ObjectParameter("uid", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetUserProfile_Result>("GetUserProfile", uidParameter);
}
public virtual ObjectResult<InternalClientsList_Result> InternalClientsList(Nullable<bool> isActive, Nullable<int> clientId)
{
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<InternalClientsList_Result>("InternalClientsList", isActiveParameter, clientIdParameter);
}
public virtual ObjectResult<MonthlyDetailReport_Result> MonthlyDetailReport(Nullable<int> month_number, string expenseType, string eventName)
{
var month_numberParameter = month_number.HasValue ?
new ObjectParameter("Month_number", month_number) :
new ObjectParameter("Month_number", typeof(int));
var expenseTypeParameter = expenseType != null ?
new ObjectParameter("ExpenseType", expenseType) :
new ObjectParameter("ExpenseType", typeof(string));
var eventNameParameter = eventName != null ?
new ObjectParameter("eventName", eventName) :
new ObjectParameter("eventName", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<MonthlyDetailReport_Result>("MonthlyDetailReport", month_numberParameter, expenseTypeParameter, eventNameParameter);
}
public virtual ObjectResult<MonthlyReport_Result> MonthlyReport()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<MonthlyReport_Result>("MonthlyReport");
}
public virtual ObjectResult<ProjectFilesList_Result> ProjectFilesList(Nullable<int> projectId, Nullable<int> clientId, Nullable<bool> isActive)
{
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ProjectFilesList_Result>("ProjectFilesList", projectIdParameter, clientIdParameter, isActiveParameter);
}
public virtual ObjectResult<ProjectsList_Result> ProjectsList(Nullable<bool> isActive, Nullable<int> clientId, string employeeId)
{
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
var employeeIdParameter = employeeId != null ?
new ObjectParameter("EmployeeId", employeeId) :
new ObjectParameter("EmployeeId", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ProjectsList_Result>("ProjectsList", isActiveParameter, clientIdParameter, employeeIdParameter);
}
public virtual int RemoveFilesProject(string fileName, string filePath, Nullable<System.DateTime> uploadedDate, Nullable<bool> isActive, string updatedBy, Nullable<int> projectId, Nullable<int> fileId, Nullable<int> clientId)
{
var fileNameParameter = fileName != null ?
new ObjectParameter("FileName", fileName) :
new ObjectParameter("FileName", typeof(string));
var filePathParameter = filePath != null ?
new ObjectParameter("FilePath", filePath) :
new ObjectParameter("FilePath", typeof(string));
var uploadedDateParameter = uploadedDate.HasValue ?
new ObjectParameter("UploadedDate", uploadedDate) :
new ObjectParameter("UploadedDate", typeof(System.DateTime));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var updatedByParameter = updatedBy != null ?
new ObjectParameter("UpdatedBy", updatedBy) :
new ObjectParameter("UpdatedBy", typeof(string));
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
var fileIdParameter = fileId.HasValue ?
new ObjectParameter("FileId", fileId) :
new ObjectParameter("FileId", typeof(int));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("RemoveFilesProject", fileNameParameter, filePathParameter, uploadedDateParameter, isActiveParameter, updatedByParameter, projectIdParameter, fileIdParameter, clientIdParameter);
}
public virtual ObjectResult<ReportTypeList_Result> ReportTypeList()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ReportTypeList_Result>("ReportTypeList");
}
public virtual int SaveInternalClients(string clientName, string primaryContactName, string emailId, string primaryContact, string modifiedBy, Nullable<bool> isActive, Nullable<int> parentCompany)
{
var clientNameParameter = clientName != null ?
new ObjectParameter("ClientName", clientName) :
new ObjectParameter("ClientName", typeof(string));
var primaryContactNameParameter = primaryContactName != null ?
new ObjectParameter("PrimaryContactName", primaryContactName) :
new ObjectParameter("PrimaryContactName", typeof(string));
var emailIdParameter = emailId != null ?
new ObjectParameter("EmailId", emailId) :
new ObjectParameter("EmailId", typeof(string));
var primaryContactParameter = primaryContact != null ?
new ObjectParameter("PrimaryContact", primaryContact) :
new ObjectParameter("PrimaryContact", typeof(string));
var modifiedByParameter = modifiedBy != null ?
new ObjectParameter("ModifiedBy", modifiedBy) :
new ObjectParameter("ModifiedBy", typeof(string));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var parentCompanyParameter = parentCompany.HasValue ?
new ObjectParameter("ParentCompany", parentCompany) :
new ObjectParameter("ParentCompany", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SaveInternalClients", clientNameParameter, primaryContactNameParameter, emailIdParameter, primaryContactParameter, modifiedByParameter, isActiveParameter, parentCompanyParameter);
}
public virtual ObjectResult<SaveProjects_Result> SaveProjects(string projectName, Nullable<System.DateTime> startDate, Nullable<System.DateTime> endDate, Nullable<bool> isActive, Nullable<System.DateTime> createdDate, string createdBy, Nullable<System.DateTime> updatedDate, string updatedBy, Nullable<int> clientId, string employees, string reportType)
{
var projectNameParameter = projectName != null ?
new ObjectParameter("ProjectName", projectName) :
new ObjectParameter("ProjectName", typeof(string));
var startDateParameter = startDate.HasValue ?
new ObjectParameter("StartDate", startDate) :
new ObjectParameter("StartDate", typeof(System.DateTime));
var endDateParameter = endDate.HasValue ?
new ObjectParameter("EndDate", endDate) :
new ObjectParameter("EndDate", typeof(System.DateTime));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var createdDateParameter = createdDate.HasValue ?
new ObjectParameter("CreatedDate", createdDate) :
new ObjectParameter("CreatedDate", typeof(System.DateTime));
var createdByParameter = createdBy != null ?
new ObjectParameter("CreatedBy", createdBy) :
new ObjectParameter("CreatedBy", typeof(string));
var updatedDateParameter = updatedDate.HasValue ?
new ObjectParameter("UpdatedDate", updatedDate) :
new ObjectParameter("UpdatedDate", typeof(System.DateTime));
var updatedByParameter = updatedBy != null ?
new ObjectParameter("UpdatedBy", updatedBy) :
new ObjectParameter("UpdatedBy", typeof(string));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
var employeesParameter = employees != null ?
new ObjectParameter("Employees", employees) :
new ObjectParameter("Employees", typeof(string));
var reportTypeParameter = reportType != null ?
new ObjectParameter("ReportType", reportType) :
new ObjectParameter("ReportType", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<SaveProjects_Result>("SaveProjects", projectNameParameter, startDateParameter, endDateParameter, isActiveParameter, createdDateParameter, createdByParameter, updatedDateParameter, updatedByParameter, clientIdParameter, employeesParameter, reportTypeParameter);
}
public virtual int UpdateInternalClients(Nullable<int> clientId, string clientName, string primaryContactName, string emailId, string primaryContact, string modifiedBy, Nullable<bool> isActive, Nullable<int> parentCompany)
{
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
var clientNameParameter = clientName != null ?
new ObjectParameter("ClientName", clientName) :
new ObjectParameter("ClientName", typeof(string));
var primaryContactNameParameter = primaryContactName != null ?
new ObjectParameter("PrimaryContactName", primaryContactName) :
new ObjectParameter("PrimaryContactName", typeof(string));
var emailIdParameter = emailId != null ?
new ObjectParameter("EmailId", emailId) :
new ObjectParameter("EmailId", typeof(string));
var primaryContactParameter = primaryContact != null ?
new ObjectParameter("PrimaryContact", primaryContact) :
new ObjectParameter("PrimaryContact", typeof(string));
var modifiedByParameter = modifiedBy != null ?
new ObjectParameter("ModifiedBy", modifiedBy) :
new ObjectParameter("ModifiedBy", typeof(string));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var parentCompanyParameter = parentCompany.HasValue ?
new ObjectParameter("ParentCompany", parentCompany) :
new ObjectParameter("ParentCompany", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("UpdateInternalClients", clientIdParameter, clientNameParameter, primaryContactNameParameter, emailIdParameter, primaryContactParameter, modifiedByParameter, isActiveParameter, parentCompanyParameter);
}
public virtual ObjectResult<UpdateProjects_Result> UpdateProjects(Nullable<int> projectId, string projectName, Nullable<System.DateTime> startDate, Nullable<System.DateTime> endDate, Nullable<bool> isActive, Nullable<System.DateTime> createdDate, string createdBy, Nullable<System.DateTime> updatedDate, string updatedBy, Nullable<int> clientId, Nullable<bool> isAnalyticsStart, Nullable<bool> isAnalyticsEnd, string employees, string reportType)
{
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
var projectNameParameter = projectName != null ?
new ObjectParameter("ProjectName", projectName) :
new ObjectParameter("ProjectName", typeof(string));
var startDateParameter = startDate.HasValue ?
new ObjectParameter("StartDate", startDate) :
new ObjectParameter("StartDate", typeof(System.DateTime));
var endDateParameter = endDate.HasValue ?
new ObjectParameter("EndDate", endDate) :
new ObjectParameter("EndDate", typeof(System.DateTime));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var createdDateParameter = createdDate.HasValue ?
new ObjectParameter("CreatedDate", createdDate) :
new ObjectParameter("CreatedDate", typeof(System.DateTime));
var createdByParameter = createdBy != null ?
new ObjectParameter("CreatedBy", createdBy) :
new ObjectParameter("CreatedBy", typeof(string));
var updatedDateParameter = updatedDate.HasValue ?
new ObjectParameter("UpdatedDate", updatedDate) :
new ObjectParameter("UpdatedDate", typeof(System.DateTime));
var updatedByParameter = updatedBy != null ?
new ObjectParameter("UpdatedBy", updatedBy) :
new ObjectParameter("UpdatedBy", typeof(string));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
var isAnalyticsStartParameter = isAnalyticsStart.HasValue ?
new ObjectParameter("IsAnalyticsStart", isAnalyticsStart) :
new ObjectParameter("IsAnalyticsStart", typeof(bool));
var isAnalyticsEndParameter = isAnalyticsEnd.HasValue ?
new ObjectParameter("IsAnalyticsEnd", isAnalyticsEnd) :
new ObjectParameter("IsAnalyticsEnd", typeof(bool));
var employeesParameter = employees != null ?
new ObjectParameter("Employees", employees) :
new ObjectParameter("Employees", typeof(string));
var reportTypeParameter = reportType != null ?
new ObjectParameter("ReportType", reportType) :
new ObjectParameter("ReportType", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<UpdateProjects_Result>("UpdateProjects", projectIdParameter, projectNameParameter, startDateParameter, endDateParameter, isActiveParameter, createdDateParameter, createdByParameter, updatedDateParameter, updatedByParameter, clientIdParameter, isAnalyticsStartParameter, isAnalyticsEndParameter, employeesParameter, reportTypeParameter);
}
public virtual ObjectResult<UploadFilesProject_Result> UploadFilesProject(Nullable<int> projectId, string fileName, string filePath, Nullable<System.DateTime> uploadedDate, Nullable<bool> isActive, string updatedBy, Nullable<int> clientId)
{
var projectIdParameter = projectId.HasValue ?
new ObjectParameter("ProjectId", projectId) :
new ObjectParameter("ProjectId", typeof(int));
var fileNameParameter = fileName != null ?
new ObjectParameter("FileName", fileName) :
new ObjectParameter("FileName", typeof(string));
var filePathParameter = filePath != null ?
new ObjectParameter("FilePath", filePath) :
new ObjectParameter("FilePath", typeof(string));
var uploadedDateParameter = uploadedDate.HasValue ?
new ObjectParameter("UploadedDate", uploadedDate) :
new ObjectParameter("UploadedDate", typeof(System.DateTime));
var isActiveParameter = isActive.HasValue ?
new ObjectParameter("IsActive", isActive) :
new ObjectParameter("IsActive", typeof(bool));
var updatedByParameter = updatedBy != null ?
new ObjectParameter("UpdatedBy", updatedBy) :
new ObjectParameter("UpdatedBy", typeof(string));
var clientIdParameter = clientId.HasValue ?
new ObjectParameter("ClientId", clientId) :
new ObjectParameter("ClientId", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<UploadFilesProject_Result>("UploadFilesProject", projectIdParameter, fileNameParameter, filePathParameter, uploadedDateParameter, isActiveParameter, updatedByParameter, clientIdParameter);
}
public virtual ObjectResult<validateuser_Result> validateuser(string username, string password)
{
var usernameParameter = username != null ?
new ObjectParameter("username", username) :
new ObjectParameter("username", typeof(string));
var passwordParameter = password != null ?
new ObjectParameter("password", password) :
new ObjectParameter("password", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<validateuser_Result>("validateuser", usernameParameter, passwordParameter);
}
}
}
我该如何解决这个问题?我正在使用appsetting连接和EntityFramework