When using EF 4.1 Code First, is it possible to create User-Defined Data Types for your schema?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple answer is no.
Longer answer:
Current EF implementation leads to multiple issues when trying to use user defined types:
Seedmethod of database initializer (as often used for other database constructs like triggers or indexes). To make this work you must create whole new initializer by implementingIDatabaseInitializerand separate database creation and table creation because custom type definitions must be between them. Here is some example how to create database initializer (this one will recreate tables every time you run the application).ColumnAttributeandHasColumnTypein fluent API will accept custom type. So your mapping must specify basic primitive SQL types and these custom types will be used in tables DDL produced by EF. So unless custom database initializer post-process those generated SQL scripts and replaces basic types with custom types (really ugly solution) tables will not use them.