Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF6 can't generate a citext column when doing database-first #1029

Closed
M144-Coder opened this issue Apr 18, 2016 · 9 comments
Closed

EF6 can't generate a citext column when doing database-first #1029

M144-Coder opened this issue Apr 18, 2016 · 9 comments

Comments

@M144-Coder
Copy link

Details are in my stackoverflow question

http://stackoverflow.com/questions/36675132/citext-data-type-in-entity-framework-6-1-3

@roji
Copy link
Member

roji commented Apr 19, 2016

@M144-Coder citext was introduced in Npgsql (at the ADO.NET layer), but that doesn't mean it's supported in EF6...

@Emill want to take a look at this?

@Emill
Copy link
Contributor

Emill commented Apr 19, 2016

I'm not really sure how the Code First approach works. Are you generating the database from C# specifications or have you already created your database and trying to get a model that works with it? Could you possibly send the stack trace?

The normal way as far as I know for EF-non-supported data types have been to trick Entity Framework that the data type is simply text/string but the real data type is something else.

@M144-Coder
Copy link
Author

Code first from database approach is the same as Code First approach except that the model is auto generated for you from existing database (with no edmx files) the rest is the same as code first approach.
Why to trick EF? I think supporting citex type in EF won't be that hard because it's already supported in ADO.NET

@Emill
Copy link
Contributor

Emill commented Apr 20, 2016

Unfortunately no, EF only supports the primitive types https://msdn.microsoft.com/en-us/library/ee382832(v=vs.110).aspx as well as some SQL Server specific geometry types.

@roji
Copy link
Member

roji commented Apr 20, 2016

@M144-Coder is your problem specifically doing database-first (i.e. generating a C# code-first model from an existing database)? I think you should be able to do code-first by writing your C# model yourself by hand (or taking a database-first generated model and tweaking it), and "tricking" EF6 as @Emill said.

@M144-Coder
Copy link
Author

@roji That is a good workaround, Thanks for your help

@roji
Copy link
Member

roji commented Apr 20, 2016

Am going to close this because I don't think there's going to be a way to make EF6 database-first generate C# code that will do citext. For any issues using normal code-first feel free to open a new issue.

@roji roji closed this as completed Apr 20, 2016
@roji roji removed the up for grabs label Apr 20, 2016
@roji roji changed the title The data type citext is currently not supported for the target Entity Framework version EF6 can't generate a citext column when doing database-first Apr 20, 2016
@jducobu
Copy link

jducobu commented Apr 14, 2019

Is citext column type now supported with EF Core when doing model-first ?

@roji
Copy link
Member

roji commented Apr 16, 2019

@jducobu it's supported with a few caveats related to type inference (and should be better supported when EF Core 3.0 comes out). Simply manually define your the column's store type to be citext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants