-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
RelationalModelValidatorTest.PropertyMapping.cs
42 lines (36 loc) · 1.78 KB
/
RelationalModelValidatorTest.PropertyMapping.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore.Infrastructure;
public partial class RelationalModelValidatorTest
{
[ConditionalFact]
public void Throws_when_added_property_is_not_mapped_to_store()
{
var modelBuilder = CreateConventionlessModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveAsPropertyEntity));
entityTypeBuilder.Property(typeof(Tuple<long>), "LongProperty");
entityTypeBuilder.Ignore(nameof(NonPrimitiveAsPropertyEntity.Property));
Assert.Equal(
CoreStrings.PropertyNotMapped(
typeof(Tuple<long>).ShortDisplayName(),
typeof(NonPrimitiveAsPropertyEntity).ShortDisplayName(),
"LongProperty"),
Assert.Throws<InvalidOperationException>(() => Validate(modelBuilder)).Message);
}
[ConditionalFact]
public void Throws_when_added_property_is_not_mapped_to_store_even_if_configured_to_use_column_type()
{
var modelBuilder = CreateConventionlessModelBuilder();
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveNonNavigationAsPropertyEntity));
entityTypeBuilder.Property(typeof(Tuple<long>), "LongProperty")
.HasColumnType("some_int_mapping");
Assert.Equal(
RelationalStrings.PropertyNotMapped(
typeof(Tuple<long>).ShortDisplayName(),
typeof(NonPrimitiveNonNavigationAsPropertyEntity).ShortDisplayName(),
"LongProperty",
"some_int_mapping"),
Assert.Throws<InvalidOperationException>(() => Validate(modelBuilder)).Message);
}
}