문제

Why in, C# ASP.NET MVC Code First project, POCO Classes must have getters and setters ( {get; set; } ) in order to work?

public float data { get; set; }

or in db context class

public DbSet<SGD.Models.MyData> MyData{ get; set; }

I just don't understand why a simple attribute (without getters and setters) doesn't works.

도움이 되었습니까?

해결책

Because Microsoft decided to only support properties in Entity Framework.

There are many reasons why properties are preferred over public fields, but I'll just mention the one that I think is most relevant here: changing from public fields to properties (if the need arises) is a binary breaking change.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top