none
Invalid object name dbo.PortfolioSubStrategyHistories RRS feed

  • Question

  • I know there's a lot of posts with this error, but I'm not getting a resolution using the suggestions from those posts. I've already checked that I'm going to the correct db from my mvc app, which I am, and that I am able to hit other tables/entities, which I am. I've also tried deleting this table and recreating it. Here's the exact innerexception that I get:

    Invalid object name 'dbo.HedgeFundSubStrategyHistories'.

       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

    This is the code that causes the exception

    List<HedgeFundPerformance> hedgefundPerformances = new List<HedgeFundPerformance>();
                    foreach (var subStrat in pSubStrategies)
                    {
                        var result = from hfp in KrisDb.FundPerformances.OfType<HedgeFundPerformance>()
                                     join hfh in KrisDb.HedgeFundSubStrategyHistories on hfp.HedgeFundID equals hfh.HedgeFundID
                                     where hfh.SubStrategyID == subStrat.SubStrategyID && hfp.PeriodID == pPeriod.PeriodID
                                     select hfp;
                        hedgefundPerformances.AddRange(result.ToList());
                    }
                    return hedgefundPerformances;

    The dbcontext is defined with this entity like this

    public DbSet<HedgeFundSubStrategyHistory> HedgeFundSubStrategyHistories { get; set; }

    Sunday, March 11, 2012 8:26 PM

Answers

All replies