How to manually configure the database type for a property in EF Core?

c# entity-framework-core sql-server

Question

I have a class:

class Order
{
    public OrderId Id {get;set;}
}

struct OrderId
{
    private int readonly id;

    public OrderId(int id)
    {
        this.id = id;
    }
}

For some reason, I don't want to use a primitive type for the property. When I'm trying to save object of this class to Sql Server through Entity Framework Core, I get an error:

System.InvalidOperationException: 'The property 'Order.Id' is of type 'OrderId' which is not supported by current database provider. Either change the property CLR type or manually configure the database type for it.'

Question: Is it possible to configure mapping in such a case and how to do it?

1
1
8/8/2017 5:17:49 PM

Accepted Answer

This is not supported at present in EF Core (upto version 2.0) For tracking issue and possible work-around see https://github.com/aspnet/EntityFramework/issues/9194

0
8/11/2017 11:28:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow