.NET Development
How to use SQL Server updateable view from Code First Entity Framework?
Gravatar is a globally recognized avatar based on your email address. How to use SQL Server updateable view from Code First Entity Framework?
  Alejandro A Sosa
  All
  Mar 31, 2015 @ 11:11am
I'm starting a Code First Entity Framework based application and I'm glad (thank you Rick).

The application has three related tables which are best thought of as a view. Even though I have never used an updateable view in SQLServer, I think that in this case that it's probably the best thing, but I don't know how to do it with a code first approach. I googled the question and did not find an answer.

Any links or suggestions would be appreciated. TIA,

Alex

Gravatar is a globally recognized avatar based on your email address. Re: How to use SQL Server updateable view from Code First Entity Framework?
  Rick Strahl
  Alejandro A Sosa
  Mar 31, 2015 @ 01:38pm
There's no such thing as an updateable view in SQL Server. That's a FoxPro thing AFAIK. You can create Views which are read only, but if you're using CodeFirst you really shouldn't use those but think about how the queries are built to access this data.

If you need to have some sort of view to make this work you might want to rethink how that data is laid out structurally (in general). The relationships you have seem overly complex as you have nested upon nested relationships that could possibly be collapsed.

+++ Rick ---



I'm starting a Code First Entity Framework based application and I'm glad (thank you Rick).

The application has three related tables which are best thought of as a view. Even though I have never used an updateable view in SQLServer, I think that in this case that it's probably the best thing, but I don't know how to do it with a code first approach. I googled the question and did not find an answer.

Any links or suggestions would be appreciated. TIA,

Alex



Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: How to use SQL Server updateable view from Code First Entity Framework?
  Alejandro A Sosa
  Rick Strahl
  Apr 1, 2015 @ 07:43am
Thanks Rick.

Regarding flattening the tables, we used that approach in another application but as a result some data was repeated in several records and we had to jump hoops to keep them in synch.

Alex



There's no such thing as an updateable view in SQL Server. That's a FoxPro thing AFAIK. You can create Views which are read only, but if you're using CodeFirst you really shouldn't use those but think about how the queries are built to access this data.

If you need to have some sort of view to make this work you might want to rethink how that data is laid out structurally (in general). The relationships you have seem overly complex as you have nested upon nested relationships that could possibly be collapsed.

+++ Rick ---



I'm starting a Code First Entity Framework based application and I'm glad (thank you Rick).

The application has three related tables which are best thought of as a view. Even though I have never used an updateable view in SQLServer, I think that in this case that it's probably the best thing, but I don't know how to do it with a code first approach. I googled the question and did not find an answer.

Any links or suggestions would be appreciated. TIA,

Alex



© 1996-2024