Generate model code