Error:-{"Invalid object name 'dbo.tbllogins'."}
Solution:=
This is just an example, you apply your own table name to fix this error.
Please see the following files to understand about the error:
public class tbllogin
{
[Key]
public int userid { get; set; }
public string username { get; set; }
public string email { get; set; }
public string password { get; set; }
public int contactno { get; set; }
}
public class UserDetailsController : ApiController
{
InfoDBContext objdbcontext = new InfoDBContext();
[HttpGet]
public IEnumerable Get()
{
if (objdbcontext.Database.Connection.State == System.Data.ConnectionState.Closed)
{
objdbcontext.Database.Connection.Open();
}
return objdbcontext.tbllogins.ToList();
}
}
If you run the above api,then you will receive following error.
{"Invalid object name 'dbo.tbllogins'."}
So how will you fix it?
Actually the compiler is getting confused between your api tablename and sqlserver tablename.
So you have to give same tablename as sqlserver tablename.For eg:- in my case i need to include Table in tbllogin.cs