문제

Is there a way to tell EF not to update SSDL for the single table when doing Update Model From Database?

A little more details:
We're using EF 4.3 with Db-first approach (so, edmx and Update Model From Database).

We have a table that for some reasons does not have a primary key set in SQL Server, but have an auto-incremented Identity column that we can tell EF to use as primary key.

Since EF isn't finding any primary key in a table itself, it generates a DefiningQuery in SSDL for that table (and prevent update/inserts).

I can easily delete that DefiningQuery (and modify other EntitySet attributes) and everything works fine.

Except when I do another Update Model From Database that DefiningQuery is back again.

Is there a way to tell EF not to update SSDL for that single table?

도움이 되었습니까?

해결책

Is there a way to tell EF not to update SSDL for the single table when doing Update Model From Database?

Not with default designer provided in Visual Studio. Once you modify SSDL part of your EDMX file you should maintain it manually or write a script which will fix it every time you run Update from database.

Alternatively you can buy more powerful designer or extension to Visual Studio which will offer you selective update.

Anyway what you are trying to do should be avoided. If the database is owned by ERP you should do the access only through ERP programming API (real ERP has some). Otherwise you can break functionality of your ERP, corrupt ERP data, cause performance issues or even cause deadlocks.

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