I'm new to EF, so I need your support. Every time I actualize my EF Model from database (Database First), EF creates the method "OnModelCreating":
Namespace FDB.Model
Partial Public Class FDBEntities
Inherits DbContext
Public Sub New()
MyBase.New("name=FDBEntities")
End Sub
Protected Overrides Sub OnModelCreating(modelBuilder As DbModelBuilder)
Throw New UnintentionalCodeFirstException()
End Sub
In this method, the "UnintentionalCodeFirstException" will be thrown. How can I prevent EF from creating this exception? Everytime I change this method, EF of course will override it when the model is actualized. I already created a second class "Partial Public FDBEntities" with a "On ModelCreating"-method in it, but that won't work:
Partial Public Class FDBEntities
Inherits DbContext
Protected Overrides Sub OnModelCreating(modelBuilder As DbModelBuilder)
MyBase.OnModelCreating(modelBuilder)
End Sub
End Class
After actualizing the EDM, this method will be underlined red, because there already exists a method with identical signature.
FYI: Initially I indeed use Code First, but I completely removed the Datalayer (folders and files) and create a new one with Database First, so I think, this cannot be the reason for this exception.