I am using this command in the Package Manager Console:
Scaffold-DbContext "data source=SOURCENAME;initial catalog=INTERBASE_DB;user id=username;password=password" InterBaseSQL.EntityFrameworkCore.InterBase -Tables tableName –o dbModel
It builds correctly and then gives me the Object cannot be cast from DBNull to other types error.
All the solutions I am finding online have to deal with code rather than the scaffold command. Even though my database exists and has NULL values, should I still be able to scaffold? The connection to the database is fine as I can print out all the data…
var cs = BuildConnectionStringBuilder().ToString();
using (var connection = new IBConnection(cs))
{
connection.Open();
using (var transaction = connection.BeginTransaction())
{
using (var command = new IBCommand("select * from artcust", connection, transaction))
{
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
var values = new object[reader.FieldCount];
reader.GetValues(values);
Console.WriteLine(string.Join("|", values));
}
return new object[6];
}
}
}
}
My model would be a lot of manual typing of code and really do not want to do that!
Caleb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.