7

I have the following class which is a model for a database table:

public class User : IUser
{
    internal int Id { get; set; }

    public string Name { get; set; }
    public string Email { get; set; }

    public ITest TestData { get; set; }
}

When I run Update-Database command, it throws an error:

The property User.TestData is of an interface type (ITest). If it is a navigation property manually configure the relationship for this property by casting it to a mapped entity type

How and where can I manually configure the relationship for this property if I do not want the actual property to be a class?

Elijah Dollin
  • 157
  • 1
  • 3
  • 12
  • https://stackoverflow.com/questions/43161458/the-property-is-of-an-interface-type-iformfile-mvc-core/43161520 – Guy Jan 14 '18 at 13:47
  • 1
    https://stackoverflow.com/questions/9805329/how-to-use-interface-properties-with-codefirst – Levanan Gan Jan 14 '18 at 14:01

1 Answers1

7

EF does not support interfaces, but you can deal with it this way. Take a look on this solution How to use interface properties with CodeFirst

Nove124
  • 223
  • 2
  • 6