asp.net mvc - An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code -


i new asp.net mvc, facing exception, connection string looks perfect still, exception raised, appreciate if give me why happening.

thank guys

model 1

namespace mvctwice.models {     public class studentcontext : dbcontext     {         public dbset<student> studs { get; set; }     } } 

model 2

namespace mvctwice.models {     [table("tblstudents")]     public class student     {         public int id { get; set; }         public string name { get; set; }         public string gender { get; set; }         public string totalmarks { get; set; }     } } 

action method

public actionresult index()         {             studentcontext studentcontext = new studentcontext();             //student emp = studentcontext.studs.select(emp=>emp.)            list<student> emp=studentcontext.studs.tolist();              return view(emp);         } 

view

@model mvctwice.models.student @{     layout = null; } <!doctype html> <html> <head>     <meta name="viewport" content="width=device-width" />     <title>index</title> </head> <body>     <div>          @model.gender         @model.name         @model.id         @model.totalmarks      </div> </body> </html> 

exception

enter image description here

connectionstring

 <connectionstrings >     <add          name="myconnectionstring"          connectionstring="provider=sqloledb.1;persist security info=false;user id=sa;initial catalog=logininfo;data source=.\sqlexpress"          providername="system.data.sqlclient"/>   </connectionstrings> 

<connectionstrings>   <add name ="studentcontext "          connectionstring ="server=.; database=here database name; integrated security=sspi"            providername ="system.data.sqlclient"/> </connectionstrings> 

here code change database name , add web.config file.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -