System.ArgumentNullException in entity framework -
here's dbcontext. can see, tables in database named differently.
public class datacontext : dbcontext { public datacontext() : base("name=connstring") { } public dbset<person> personer; } [table("users")] public class person { [column("userid")] public int id { get; set; } [column("userfirstname")] public string fornavn { get; set; } [column("userlastname")] public string etternavn { get; set; } }
here's code generates system.argumentnullexception: value cannot null. parameter name: source
.
using (var db = new datacontext()) { var x = db.personer.count(); }
personer must property not field.
public class datacontext : dbcontext { public datacontext() : base("name=connstring") { } public dbset<person> personer { get; set; } }
Comments
Post a Comment