I am trying to follow a textbook tutorial, I create the model but I don't know why I cannot reference to it. Anyway, in collusion when I try to read the data from the database I get an exception, saying that the table was not found. Thank you for any help and advice.
My Code:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.EntityClient;
using System.Data.Common;
using System.Data;
using System.Configuration;
//using StockHistoryModel; This is my model and is not available.
static void Main(){
string connectionString = ConfigurationManager.ConnectionStrings
["StockHistoryEntities"].ConnectionString;
EntityConnection connection = new EntityConnection(connectionString);
connection.Open();
EntityCommand command = new EntityCommand("SELECT SymbolID FROM Shares",
connection);
DbDataReader reader = command.ExecuteReader(
CommandBehavior.SequentialAccess);
while (reader.Read())
Console.WriteLine("{0}", reader.GetValue(0));
}
}
Exception:
My Model: