I am trying to use slick codegen to create a Tables.scala file based on existing data in a SQLServer with the following settings:
slick.codegen.SourceCodeGenerator.main(Array("slick.jdbc.SQLServerProfile",
"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"jdbc:sqlserver://myserver.com:1433;applicationName=TestCodeGen;integratedSecurity=true;authenticationScheme=NativeAuthentication;databaseName=MYDB",
"src/main/scala/",
"com.mypackage",
"myUserId",
""))
When I run the command I get no errors but an empty Tables.scala file is produced (there are dozens of tables in the database):
package com.mypackage
// AUTO-GENERATED Slick data model
/** Stand-alone Slick data model for immediate use */
object Tables extends {
val profile = slick.jdbc.SQLServerProfile
} with Tables
/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
trait Tables {
val profile: slick.jdbc.JdbcProfile
import profile.api._
import slick.model.ForeignKeyAction
/** DDL for all tables. Call .create to execute. */
lazy val schema: profile.SchemaDescription = profile.DDL(Nil, Nil)
@deprecated("Use .schema instead of .ddl", "3.0")
def ddl = schema
}
My suspicion is that there is a problem with the fact that the SQLServer is using a dbo schema but that schema is not specified anywhere in the codegen call (all of the tables are named "dbo..TableName").
So my question is: do I need to specify 'dbo' somewhere in codegen configuration and if so, how?
If the answer is that there is nothing that needs to be done then how to I debug the fact that codegen is obviously failing but producing no errors?
Thank you in advance for your consideration and response.
Although for direct connection the com.microsoft driver does work, I've found for code generation you need to pass in the slick jdbc SQLServerProfile with a $.
Array("slick.jdbc.SQLServerProfile",
"slick.jdbc.SQLServerProfile$",
"jdbc:sqlserver://myserver.com:1433;applicationName=TestCodeGen;integratedSecurity=true;authenticationScheme=NativeAuthentication;databaseName=MYDB",
"src/main/scala/",
"com.mypackage",
"myUserId",
"")
If that doesn't work, try also adding a jtds driver to your library, and using a jtds styled url:
"jdbc:jtds:sqlserver://myserver.com:1433;applicationName=TestCodeGen;integratedSecurity=true;authenticationScheme=NativeAuthentication;databaseName=MYDB"
Where your jtds dependency would look like this:
libraryDependencies += "net.sourceforge.jtds" % "jtds" % "1.3.1"