您好我在azure上发布了一个应用程序.当我尝试访问BookDetail页面时,我收到InvalidColumn“Borrowed”错误.在具有PhoneNumber和Password列的UserDetail页面上也会发生同样的事情.
@H_404_5@
@H_404_5@这是BookDetail getmethod
@H_404_5@
非常感谢您的帮助.
public IQueryable<Book> GetBook([QueryString("BookID")] int? BookID) { var _db = new WebApplication1.Models.LibraryContext(); IQueryable<Book> query = _db.Books; if (BookID.HasValue && BookID > 0) { query = query.Where(p => p.BookID == BookID); } else { query = null; } if (query == null || query.Count() == 0) { inputUserBorrow.Visible = false; inputUserBorrowButton.Visible = false; } return query; }@H_404_5@这是我的模特 @H_404_5@
namespace WebApplication1.Models { public class LibUser { [Key] public int UserID { get; set; } [required,StringLength(50),display(Name = "First Name")] public string UserFirstName { get; set; } [required,display(Name = "Last Name")] public string UserLastName { get; set; } [required,StringLength(100),display(Name = "Street"),DataType(DataType.Text)] public string Adress { get; set; } [required,StringLength(20),display(Name = "Phone Number"),DataType(DataType.Text)] public string PhoneNumber { get; set; } public string Password { get; set; } } public class Book { [Key] public int BookID { get; set; } public string Title { get; set; } public string Author { get; set; } public DateTime Published { get; set; } public bool Borrowed { get; set; } public Book() { Borrowed = false; } } public class Borrowed { [Key] public int BorrowID { get; set; } public int UserID { get; set; } public int BookID { get; set; } public string BookTitle { get; set; } public DateTime Due { get; set; } }@H_404_5@} @H_404_5@这是我的上下文文件 @H_404_5@
namespace WebApplication1.Models { public class LibraryContext : DbContext { public LibraryContext() : base("LibraryContext") { } public DbSet<LibUser> LibUsers { get; set; } public DbSet<Book> Books { get; set; } public DbSet<Borrowed> Borrows { get; set; } } }@H_404_5@堆栈跟踪 @H_404_5@
[sqlException (0x80131904): Invalid column name 'Borrowed'.] System.Data.sqlClient.sqlConnection.OnError(sqlException exception,Boolean breakConnection,Action`1 wrapCloseInAction) +1787814 System.Data.sqlClient.sqlInternalConnection.OnError(sqlException exception,Action`1 wrapCloseInAction) +5341674 System.Data.sqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncclose) +546 System.Data.sqlClient.TdsParser.TryRun(RunBehavior runBehavior,sqlCommand cmdHandler,sqlDataReader dataStream,BulkcopySimpleResultSet bulkcopyHandler,TdsParserStateObject stateObj,Boolean& dataReady) +1693 System.Data.sqlClient.sqlDataReader.TryConsumeMetaData() +61 System.Data.sqlClient.sqlDataReader.get_MetaData() +90 System.Data.sqlClient.sqlCommand.FinishExecuteReader(sqlDataReader ds,RunBehavior runBehavior,String resetoptionsstring) +377 System.Data.sqlClient.sqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean returnStream,Boolean async,Int32 timeout,Task& task,Boolean asyncWrite,sqlDataReader ds) +1421 System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method,taskcompletionsource`1 completion,Boolean asyncWrite) +177 System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method) +53 System.Data.sqlClient.sqlCommand.ExecuteReader(CommandBehavior behavior,String method) +137 System.Data.sqlClient.sqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Entity.Infrastructure.Interception.DbCommanddispatcher.<Reader>b__c(DbCommand t,DbCommandInterceptionContext`1 c) +9 System.Data.Entity.Infrastructure.Interception.Internaldispatcher`1.dispatch(TTarget target,Func`3 operation,TInterceptionContext interceptionContext,Action`3 executing,Action`3 executed) +72 System.Data.Entity.Infrastructure.Interception.DbCommanddispatcher.Reader(DbCommand command,DbCommandInterceptionContext interceptionContext) +356 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) +166 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDeFinition.ExecuteStoreCommands(EntityCommand entityCommand,CommandBehavior behavior) +37@H_404_5@当我将我的应用程序发布到azure并在azure服务上使用新数据库时出现此问题.
非常感谢您的帮助.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。