I am using entity framework in asp.net mvc3 and when i try to add new record to a table i get this error. Here is my code
namespace CvGenerator.Models
{
public class LogInEntities:DbContext
{
public DbSet LogIn { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
modelBuilder.Entity<LogIn>().ToTable("LogInData");
base.OnModelCreating(modelBuilder);
}
}
}
Model controller:
public class LogIn
{
public int LogInId { get; set; }
public string NameAndSurname { get; set; }
public string Email { get; set; }
public virtual ICollection<LogIn> LogInCol { get; set; }
}
Method which i call using ajax to record data:
public void LogIn(string email,string nameAndSurname)
{
LogInEntities logIndb = new LogInEntities();
LogIn logIn = new LogIn();
if(ModelState.IsValid)
{
logIn.Email = email;
logIn.NameAndSurname = nameAndSurname;
***logIndb.LogIn.Add(logIn);***
logIndb.SaveChanges();
}
}
on marked row i get the exeption
Try DbSet<Login> Logins instead