asp.net core mvc - The required column was not present in the results of a 'FromSql' operation -


i've starting learning mvc6 ef7. have stored proc i'd return portion of fields in model. if don't return every field in model, i'm getting "the required column 'firstname' not present in results of 'fromsql' operation".

is there way make columns not required can return portion of fields in model?

model:

public class loginviewmodel {     [key]     public int userid { get; set; }      [required]     [display(name = "username")]     public string username { get; set; }      [required]     [datatype(datatype.password)]     [display(name = "password")]     public string password { get; set; }      [required]     [datatype(datatype.password)]     [display(name = "protected id")]     public string protectedid { get; set; }      public string firstname { get; set; }     public string lastname { get; set; } } 

my proc testing:

create procedure [dbo].[aaa_topxxuserstest] @numtoreturn int = 10 begin     set nocount on;     select top(@numtoreturn) userid, lastname, username,password, protectedid users deleted = 0  end 

and last, controller code:

public iactionresult index() {     var user = _context.set<loginviewmodel>().fromsql("dbo.aaa_topxxuserstest @numtoreturn = {0}", 20);      return view(user); } 

if include fields of model in stored proc call work fine, can't seem return subset. there way make of fields not required?


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -