1.I have created a demo application in loopback using "lb demo" command.
2.Then, successfully installed MySQL connectors using "npm install loopback-connector-mysql --save" this command.
3.Then create user model with firstName and lastName properties.
or can we need to manually create MySQL tables.?
Please suggest any solution. I tried a lot for this but not able to resolve the problem.
Thanks in advance.
According to your steps you never did try to auto create them.
To invoke automigrate try creating server/bin/automigrate.js
with the following code, then run node server/bin/automigrate
in your project directory
var server = require('./server');
var ds = server.dataSources.MYDATASOURCE;
var lbTables = ['myUserModel', 'anotherModelIWantToCreate'];
ds.automigrate(lbTables, function(er) {
if (er) throw er;
console.log('Loopback tables [' - lbTables - '] created in ', ds.adapter.name);
ds.disconnect();
});
https://loopback.io/doc/en/lb3/Creating-a-database-schema-from-models.html
Warning: Auto-migration will drop an existing table if its name matches a model name. When tables with data exist, use auto-update to avoid data loss.