Search code examples
entity-frameworkdata-annotationsfluent-interface

Using EF code first to generate tables with columns that have special SQL data types


I was wondering if it is possible (either through the Fluent Api or data annotations) to have a property map to the database as bit, hierarchyid, sql_variant, sysname, table, or timestamp when generating the database via code first. Really the most important one for me is sysname, I'm just curious on the rest. Has any done this? Thanks


Solution

  • Reading from here I would say no. There is no CLR type equivalent to sysname SQL type.

    I also try .HasColumnType("sysname") with no succes bu an exception on a missing namespace for non primitive type name. But as there is nothing in the CLR concerning sysname, I have no namespace to provide.

    Form here you can read that sysname is nvarchar(128) not null.

    hope this helps