PropertyBuilder<TProperty>.HasConversion Method (Microsoft.EntityFrameworkCore.Metadata.Builders) (2024)

Share via

  • Reference

Definition

Namespace:
Microsoft.EntityFrameworkCore.Metadata.Builders
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v2.1.11
Package:
Microsoft.EntityFrameworkCore v2.2.6
Package:
Microsoft.EntityFrameworkCore v3.0.0
Package:
Microsoft.EntityFrameworkCore v3.1.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

HasConversion(ValueConverter)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter.

HasConversion(Type)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion(ValueConverter, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter.

HasConversion(Type, Type)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion(ValueConverter, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter.

HasConversion(Type, ValueComparer, ValueComparer)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion(Type, ValueComparer)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion(Type, Type, Type)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer,TProviderComparer>()

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer>()

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion>()

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion>(ValueComparer)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion<TConversion>(ValueComparer, ValueComparer)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter<TModel,TProvider>.

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter<TModel,TProvider>.

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>)

Configures the property so that the property value is converted to and from the databaseusing the given conversion expressions.

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter<TModel,TProvider>.

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given conversion expressions.

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given conversion expressions.

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter converter);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter);
override this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (converter As ValueConverter) As PropertyBuilder(Of TProperty)

Parameters

converter
ValueConverter

The converter to use.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion(Type)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type providerClrType);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type? providerClrType);
override this.HasConversion : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (providerClrType As Type) As PropertyBuilder(Of TProperty)

Parameters

providerClrType
Type

The type to convert to and from or a type that inherits from ValueConverter.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
override this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (converter As ValueConverter, valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Parameters

converter
ValueConverter

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion(Type, Type)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type conversionType, Type? comparerType);
override this.HasConversion : Type * Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (conversionType As Type, comparerType As Type) As PropertyBuilder(Of TProperty)

Parameters

conversionType
Type

The type to convert to and from or a type that inherits from ValueConverter.

comparerType
Type

A type that inherits from ValueComparer.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
override this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (converter As ValueConverter, valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Parameters

converter
ValueConverter

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion(Type, ValueComparer, ValueComparer)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type conversionType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
override this.HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (conversionType As Type, valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Parameters

conversionType
Type

The type to convert to and from or a type that inherits from ValueConverter.

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type providerClrType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type conversionType, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
override this.HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
override this.HasConversion : Type * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (providerClrType As Type, valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)
Public Overridable Function HasConversion (conversionType As Type, valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Parameters

providerClrTypeconversionType
Type

The type to convert to and from.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion(Type, Type, Type)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion (Type conversionType, Type? comparerType, Type? providerComparerType);
override this.HasConversion : Type * Type * Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion (conversionType As Type, comparerType As Type, providerComparerType As Type) As PropertyBuilder(Of TProperty)

Parameters

conversionType
Type

The type to convert to and from or a type that inherits from ValueConverter.

comparerType
Type

A type that inherits from ValueComparer.

providerComparerType
Type

A type that inherits from ValueComparer to use for the provider values.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TConversion,TComparer,TProviderComparer> () where TComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer where TProviderComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer;
override this.HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property> (requires 'Comparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer and 'ProviderComparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer)
Public Overridable Function HasConversion(Of TConversion, TComparer, TProviderComparer) () As PropertyBuilder(Of TProperty)

Type Parameters

TConversion

The type to convert to and from or a type that inherits from ValueConverter.

TComparer

A type that inherits from ValueComparer.

TProviderComparer

A type that inherits from ValueComparer to use for the provider values.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion<TConversion,TComparer>()

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TConversion,TComparer> () where TComparer : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer;
override this.HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property> (requires 'Comparer :> Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer)
Public Overridable Function HasConversion(Of TConversion, TComparer) () As PropertyBuilder(Of TProperty)

Type Parameters

TConversion

The type to convert to and from or a type that inherits from ValueConverter.

TComparer

A type that inherits from ValueComparer.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> ();
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TConversion> ();
override this.HasConversion : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) () As PropertyBuilder(Of TProperty)
Public Overridable Function HasConversion(Of TConversion) () As PropertyBuilder(Of TProperty)

Type Parameters

TProvider TConversion

The type to convert to and from or a type that inherits from ValueConverter.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion<TConversion>(ValueComparer)

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TConversion> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
override this.HasConversion : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)
Public Overridable Function HasConversion(Of TConversion) (valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider TConversion

The type to convert to and from or a type that inherits from ValueConverter.

Parameters

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted beforewriting to the database and converted back when reading from the database.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TConversion> (Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
override this.HasConversion : Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TConversion) (valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Type Parameters

TConversion

The type to convert to and from or a type that inherits from ValueConverter.

Parameters

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>)

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter<TModel,TProvider>.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<TProperty,TProvider> converter);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<TProperty,TProvider>? converter);
override this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Property, 'Provider> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (converter As ValueConverter(Of TProperty, TProvider)) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider

The store type generated by the converter.

Parameters

converter
ValueConverter<TProperty,TProvider>

The converter to use.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter<TModel,TProvider>.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<TProperty,TProvider> converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<TProperty,TProvider>? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
override this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Property, 'Provider> * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (converter As ValueConverter(Of TProperty, TProvider), valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider

The store type generated by the converter.

Parameters

converter
ValueConverter<TProperty,TProvider>

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>)

Configures the property so that the property value is converted to and from the databaseusing the given conversion expressions.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (System.Linq.Expressions.Expression<Func<TProperty,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TProperty>> convertFromProviderExpression);
override this.HasConversion : System.Linq.Expressions.Expression<Func<'Property, 'Provider>> * System.Linq.Expressions.Expression<Func<'Provider, 'Property>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (convertToProviderExpression As Expression(Of Func(Of TProperty, TProvider)), convertFromProviderExpression As Expression(Of Func(Of TProvider, TProperty))) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider

The store type generated by the conversions.

Parameters

convertToProviderExpression
Expression<Func<TProperty,TProvider>>

An expression to convert objects when writing data to the store.

convertFromProviderExpression
Expression<Func<TProvider,TProperty>>

An expression to convert objects when reading data from the store.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted to and from the databaseusing the given ValueConverter<TModel,TProvider>.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<TProperty,TProvider>? converter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
override this.HasConversion : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter<'Property, 'Provider> * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (converter As ValueConverter(Of TProperty, TProvider), valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider

The store type generated by the converter.

Parameters

converter
ValueConverter<TProperty,TProvider>

The converter to use.

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>, ValueComparer)

Configures the property so that the property value is converted to and from the databaseusing the given conversion expressions.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (System.Linq.Expressions.Expression<Func<TProperty,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TProperty>> convertFromProviderExpression, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer valueComparer);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (System.Linq.Expressions.Expression<Func<TProperty,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TProperty>> convertFromProviderExpression, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer);
override this.HasConversion : System.Linq.Expressions.Expression<Func<'Property, 'Provider>> * System.Linq.Expressions.Expression<Func<'Provider, 'Property>> * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (convertToProviderExpression As Expression(Of Func(Of TProperty, TProvider)), convertFromProviderExpression As Expression(Of Func(Of TProvider, TProperty)), valueComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider

The store type generated by the conversions.

Parameters

convertToProviderExpression
Expression<Func<TProperty,TProvider>>

An expression to convert objects when writing data to the store.

convertFromProviderExpression
Expression<Func<TProvider,TProperty>>

An expression to convert objects when reading data from the store.

valueComparer
ValueComparer

The comparer to use for values before conversion.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Configures the property so that the property value is converted to and from the databaseusing the given conversion expressions.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasConversion<TProvider> (System.Linq.Expressions.Expression<Func<TProperty,TProvider>> convertToProviderExpression, System.Linq.Expressions.Expression<Func<TProvider,TProperty>> convertFromProviderExpression, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerComparer);
override this.HasConversion : System.Linq.Expressions.Expression<Func<'Property, 'Provider>> * System.Linq.Expressions.Expression<Func<'Provider, 'Property>> * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
Public Overridable Function HasConversion(Of TProvider) (convertToProviderExpression As Expression(Of Func(Of TProperty, TProvider)), convertFromProviderExpression As Expression(Of Func(Of TProvider, TProperty)), valueComparer As ValueComparer, providerComparer As ValueComparer) As PropertyBuilder(Of TProperty)

Type Parameters

TProvider

The store type generated by the conversions.

Parameters

convertToProviderExpression
Expression<Func<TProperty,TProvider>>

An expression to convert objects when writing data to the store.

convertFromProviderExpression
Expression<Func<TProvider,TProperty>>

An expression to convert objects when reading data from the store.

valueComparer
ValueComparer

The comparer to use for values before conversion.

providerComparer
ValueComparer

The comparer to use for the provider values.

Returns

PropertyBuilder<TProperty>

The same builder instance so that multiple configuration calls can be chained.

Applies to

Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.

Submit and view feedback for

PropertyBuilder<TProperty>.HasConversion Method (Microsoft.EntityFrameworkCore.Metadata.Builders) (2024)

FAQs

What is the use of Microsoft EntityFrameworkCore design? ›

They're primarily used to manage Migrations and to scaffold a DbContext and entity types by reverse engineering the schema of a database. The Microsoft. EntityFrameworkCore. Design package is required for either command-line or Package Manager Console-based tooling, and is a dependency of dotnet-ef and Microsoft.

What is the difference between Entityframework and EntityFrameworkCore? ›

Entity Framework (EF) refers to the older versions designed for the . NET Framework. Entity Framework Core (EF Core) is the modern, cross-platform ORM specifically designed for . NET Core and later versions.

What is ModelBuilder in Entity Framework Core? ›

In Entity Framework Core, the ModelBuilder class acts as a Fluent API. By using it, we can configure many different things, as it provides more configuration options than data annotation attributes.

Why do people use Entity Framework? ›

EF should be considered a great ORM framework which allows faster development, easier and quicker operations to the DB, as long as you are careful and know how it works in order to avoid certain mistakes and create performance problems.

When should I use Entity Framework? ›

With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code than in traditional applications.

Which is better MVC or Entity Framework? ›

As I've stated before, you can easily use entity framework as the M part of mvc if you need to interact with a database. I suggest you to study MVC first because will give more results (they are something that you can see), then EF. However this is a totally subjective thing.

Is Entity Framework still relevant? ›

It was retired and out of support 1.5 years later on May 10, 2022. Entity Framework Core 6.0 (EF Core 6) was released on 10 November 2021 and will be the preferred long-term supported version until at least 12 November 2024.

Is there something better than Entity Framework? ›

Because ADO.NET always establishes the connection directly to the database. That's why it provides much better performance compared to the Entity Framework. It is because, in Entity Framework, the entity first translates the LINQ queries to SQL and then it processes the query to perform database operations.

What is Entity Framework used for? ›

Entity Framework makes it easier for programmers to perform create, read, update and delete (CRUD) operations by supporting databases. It also makes it easier for developers to perform unit testing by keeping in-memory tables.

How does Entity Framework migration work? ›

EF Core Migrations is a feature of EF Core that enables developers to evolve the database schema over time in a versioned manner as the application evolves. With migrations, you can easily apply or revert database changes as your application evolves, without losing existing data.

How to do mapping in Entity Framework? ›

Here are some of the most commonly used mapping attributes in EF Core:
  1. Key: Marks a property as the primary key for the entity.
  2. Table: Specifies the name of the database table that maps to an entity.
  3. Column: Maps a property to a specific column in the database.
Feb 16, 2023

What is the Entity Framework used for? ›

Entity Framework (EF) is an object-relational mapper that enables . NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.

What are the benefits of EF core? ›

Since EF Core doesn't keep track of changes, it can be more efficient when querying a large amount of data. Reduced memory usage: Without change tracking, EF Core consumes less memory because it doesn't store information about the original state and changes of each entity.

Why use Entity Framework over Dapper? ›

Choosing between EF Core and Dapper depends on your project's needs. If you need a full-featured ORM with advanced capabilities and don't mind the extra overhead, EF Core is the way to go. On the other hand, if you need a lightweight, high-performance library and are comfortable with SQL, Dapper could be a better fit.

Is Entity Framework Core still used? ›

Entity Framework Core 5.0 (EF Core 5) was released for production use on 9 November 2020. It was retired and out of support 1.5 years later on May 10, 2022. Entity Framework Core 6.0 (EF Core 6) was released on 10 November 2021 and will be the preferred long-term supported version until at least 12 November 2024.

Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6504

Rating: 4.1 / 5 (62 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.