这是BookDetail getmethod
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; }
这是我的模特
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; }}
}
这是我的上下文文件
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; }}}
堆栈跟踪
[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
当我将我的应用程序发布到azure并在azure服务上使用新数据库时出现此问题.
非常感谢您的帮助.
以上是内存溢出为你收集整理的c# – 在azure上发布时列名无效全部内容,希望文章能够帮你解决c# – 在azure上发布时列名无效所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)