asp.net - Database is not created when i run my wcf project -


user service

i new code first ef, , wcf, have created test project contains webforms project, business logic (code first classes), wcf project services , data access later

this start file of wcf.

    public user login(string username, string password)     {         if (string.isnullorempty(username) || string.isnullorempty(password))         {             throw new exception("user name or password cannot empty");         }          var usercontext = new usercontext();         var user = usercontext.users.firstordefault(u => u.username.equals(username, stringcomparison.invariantculture) &&                                                          u.password.equals(password, stringcomparison.invariantculture));         return user;     } 

user context

public class usercontext : dbcontext {     public dbset<user> users { get; set; }      static usercontext()     {         database.setinitializer(new usercontextinitializer());     } } 

i'm missing ?

i use

using(var usercontext = new usercontext()) {    code(...) } 

you have forgotten public constructor.

public class usercontext : dbcontext {     public dbset<user> users { get; set; }      public static usercontext() : base("name of database connection string")     {         database.setinitializer(new usercontextinitializer());     } } 

Comments