Entity Framework Code First CTP5: Defining Non-Primitive Types

First I test CTP5 for entity framework code, and I ran into this problem I have a class that has a property of type Uri (System.Uri), but it seems that it cannot automatically determine how to save it, so I get an error, eg

Problem in mapping fragments starting at line 23:No mapping specified for properties WebPage.Uri in Set WebPage

How can I tell the models to map the Uri to varchar, e.g. uri url ??

+3
source share
1 answer

The actual POCO model must bind to primitive types. You can use complex type binding, for example:

[ComplexType()]
public class UriHelper
{
    public string StringRepresentation {get;set;}
    public Uri ActualUri()
    {
        return new Uri(StringRepresentation);
    }
}

, Uri, . . URI EF. . varchar nvarchar, URI. , EF , URI.

+1

Source: https://habr.com/ru/post/1791092/


All Articles