简体   繁体   中英

How does Entity Framework handle auto-implemented properties in .NET (VB.NET)?

I am new to EF and have a VB.NET project which has auto-implemented properties. How does EF handle auto-implemented properties, in that, will I have/run into issues with migrating an existing solution/DB to EF where auto-implemented properties is present?

(All the existing DB/Solution migrations I've come across so far explicitly state the get & set)

Example:

 Public Property Name As String
 Public Property Owner As String = "DefaultName"
 Public Property Items As New List(Of String) From {"M", "T", "W"}
 Public Property ID As New Guid()

Versus:

Private _Prop2 As String = "Empty"
Property Prop2 As String
Get
    Return _Prop2
End Get
Set(ByVal value As String)
    _Prop2 = value
End Set
End Property

https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/auto-implemented-properties

Thank you so much in advance.

No you won't have any issues with auto-implemented properties. It generates those auto props when using DB First.

I suggest looking into DB First, Code First or Model first. It's better to have a more solid link between your DB and code rather than a weak link which requires you to make code/db changes whenever either or is updated

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM