문제

I am new to Entity Framework and i don't know how to solve this problem.

I got an existing System.Data.Common.DbConnection with which i have to initialize the Context-Object in a Database First Scenario. I have tried this constructor

public DbContext(DbConnection existingConnection, DbCompiledModel model, bool contextOwnsConnection), 

but it looks like its only for Code First. Is it possible to use an existing DbConnection with Database First?

도움이 되었습니까?

해결책

The problem was that the DbConnection was not an Entity Connection and this means the Connection works as Code First.

It works if i create a EntityConnection with the DbConnection and create the right Workspace and then use the Entity Connection with this contructor:

public DbContext(DbConnection connection, bool contextOwnsAndDisposesTheConnection)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top