efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

Model PostgreSQL domain types

Open roji opened this issue 8 years ago • 2 comments

This would include:

  • ForNpgsqlHasDomain() to define domains with a model builder.
  • Scaffolding

roji avatar Jun 05 '18 21:06 roji

Is any domain functionality in the EF Core provider yet? I have a database that I want to use the text type for some string columns, but also want to be able to introduce a length limit. I came across this post, which suggests using domain types as a good way to do this, but I can't tell if this provider supports them at all https://www.depesz.com/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/

Or is there a better way than domain types?

jcotton42 avatar Jun 15 '22 01:06 jcotton42

@jcotton42 you should already be able to use domain types - the provider just doesn't provide functionailty to create them or scaffold them. In other words, use raw SQL to create your domain type, and then just specify that certain properties should use that as their column type with HasColumnType.

Let me know if you run into any trouble with that.

roji avatar Jun 15 '22 11:06 roji