SQL Server: support for mapping user defined types (UDT)

Open
#12,796 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, sql

Research direction

Start by reading the SqlClient for .NET Core 2.1 changes and the linked corefx issue 29139, then trace the EF Core SQL Server provider’s type-mapping and query paths. Done means custom UDT mappings can be registered and values can be read, passed as parameters, and used as literals, without expanding scope to spatial or hierarchyid support.

Written by the indexing model from the issue text.

Description

area-infrastructure area-sqlserver

This issue is about being able to use properties of .NET types that are registered as UDT types on SQL Server.

This issue is not about supporting SQL Server spatial or hierarchyid types, which happen to be implemented like UDTs. Directly mapping to SQL Server spatial types is already enabled in 2.1 wherever the types are available (currently only .NET Framework), and our full spatial story is tracked at https://github.com/aspnet/EntityFrameworkCore/issues/1100. I am splitting this issue from supporting hierachyid that was originally reported at https://github.com/aspnet/EntityFrameworkCore/issues/365, because I believe in order to property support hierarchyid we would need additional function mapping.

Enabling SQL Server UDTs would involve adding APIs to register custom type mappings and making sure you can issue queries that read values or pass parameters or even literals of these types.

The necessary features were added in SqlClient for .NET Core in 2.1. Note that UDTs need CLR types that are registered on the server and available on the client for the ADO.NET layer. SqlClient’s mechanism happens to be very simple but also inflexible. Here is a call to create a true plug-in model:
https://github.com/dotnet/corefx/issues/29139.

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.