-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I just followed the following tutorial (https://docs.strongloop.com/display/public/LB/Connect+your+API+to+a+data+source) and I was able to see the CoffeeShop table in my SQL Server Express 2014. However, as soon as I change the dataSource for the built-in models (User, Application, etc.) I get the following error: "Cannot migrate models not attached to this datasource: Application".
Any idea what is going on?
Thank you!
create-sample-model.js
module.exports = function(app) {
app.dataSources.sqlserver.automigrate(['User', 'Application', 'Role', 'ACL', 'RoleMapping', 'AccessToken'], function(err) {
if (err) throw err;
});
app.dataSources.sqlserver.automigrate('CoffeeShop', function(err) {
if (err) throw err;
app.models.CoffeeShop.create([
{name: 'Bel Cafe', city: 'Vancouver'},
{name: 'Three Bees Coffee House', city: 'San Mateo'},
{name: 'Caffe Artigiano', city: 'Vancouver'},
], function(err, coffeeShops) {
if (err) throw err;
console.log('Models created: \n', coffeeShops);
});
});
};
model-config.json
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"User": {
"dataSource": "sqlserver"
},
"AccessToken": {
"dataSource": "sqlserver",
"public": false
},
"ACL": {
"dataSource": "sqlserver",
"public": false
},
"RoleMapping": {
"dataSource": "sqlserver",
"public": false
},
"Role": {
"dataSource": "sqlserver",
"public": false
},
"CoffeeShop": {
"dataSource": "sqlserver"
}
}
datasources.json
{
"sqlserver": {
"host": "MyMachine",
"database": "demo",
"username": "User",
"password": "password",
"name": "sqlserver",
"connector": "mssql",
"debug": true,
"options": {
"encrypt": false,
"instance": "SQLEXPRESS"
}
}
}
Metadata
Metadata
Assignees
Labels
No labels