Pregunta

I'm trying to port my rails webapp to C#(mono), and I want to use the same database. When I try to create the Linq schema using sqlmetal I get this error message:

sqlmetal: System.ArgumentException: Don't know how to convert the SQL type 'name' into a managed type.
Parameter name: dataType
  at DbLinq.Vendor.Implementation.SchemaLoader.MapDbType (System.String columnName, IDataType dataType) [0x00000] in <filename unknown>:0 
  at DbLinq.Vendor.Implementation.SchemaLoader.LoadColumns (DbLinq.Schema.Dbml.Database schema, DbLinq.Schema.SchemaName schemaName, IDbConnection conn, INameAliases nameAliases, DbLinq.Schema.NameFormat nameFormat, DbLinq.Vendor.Implementation.Names names) [0x00000] in <filename unknown>:0 
  at DbLinq.Vendor.Implementation.SchemaLoader.Load (System.String databaseName, INameAliases nameAliases, DbLinq.Schema.NameFormat nameFormat, Boolean loadStoredProcedures, System.String contextNamespace, System.String entityNamespace) [0x00000] in <filename unknown>:0 
  at DbMetal.Generator.Implementation.Processor.ReadSchema (DbMetal.Parameters parameters, ISchemaLoader& schemaLoader) [0x00000] in <filename unknown>:0 
  at DbMetal.Generator.Implementation.Processor.ProcessSchema (DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0 

My database uses two extensions: hstore and PostGIS. When I remove those two extensions, sqlmetal manages to create the schema properly. Both extensions cause the error - when I remove only one(tried with both) I still get it. Ofcourse, removing those extensions is not really an option...

From what I can figure out, the problem is that sqlmetal does not understand the custom types defined in those extensions. I've searched the web and found out that I need to use a custom schema loader to define how to handle those types, and sqlmetal's embedded documentations says I should do it with --with-schema-loader - but I still can't find how to do it:

  • --with-schema-loader defines the class used as the custom loader, but where can I specify the DLL file that contains that class?
  • How am I supposed to write that schema loader? I can't find an example, but the embedded documentation says it needs to implement ISchemaLoader. I can't find it's documentation, and it's source code doesn't tell me anything(I expected something like MyBatis' YypeHandlers...)

Can anyone give me a lead on how to to this?

¿Fue útil?

Solución

My final solution was to not use Linq to SQL at all, and instead use a micro ORM(PetaPoco)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top