can't connect to SQL Server 2008 remote DB MVC4

adultmasti

New Member
I have looked in to one of the solution you provided for unable to connecting to the SQL Server 2008 in mvc4..I followed your answer but even though i am getting error.\[code\]public class videoDBContext : DbContext{ static videoDBContext() { Database.SetInitializer<videoDBContext>(null); } public videoDBContext() : base("Name=videoDBContext") { } public DbSet<Video> Videos { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Configurations.Add(new VideoMap()); } }\[/code\]domain class\[code\] public class Video { public int Id { get; set; } public string Description { get; set; } }\[/code\]Mapping class as\[code\] public class VideoMap : EntityTypeConfiguration<Video> { public VideoMap() { // Primary Key this.HasKey(t => t.Id); // Properties this.Property(t => t.Description) .IsRequired() .HasMaxLength(50); // Table & Column Mappings this.ToTable("Video"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.Description).HasColumnName("Description"); }}\[/code\]Controller action as\[code\] public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; using (videoDBContext context = new videoDBContext()) { var list = **context.Videos.ToList();** } return View(); }\[/code\]I am getting error near the line:\[code\] Line 20: var s = context.Videos.ToList();\[/code\]\[code\]web.config\[/code\] file is\[code\]<add name="videoDBContext" connectionString="metadata=res://*/Models.xx.csdl|res://*/Models.xx.ssdl|res://*/Models.xx.msl;provider=System.Data.SqlClient;provider connection string="data source=servername;initial catalog=xx.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />\[/code\]Please provide the solution. where am I going wrong? And sorry if it is silly or making you to inconvenience.
 
Back
Top