您可以使用Entity Framework 4.1代码优先方法创建sql视图/存储过程吗 [英] Can you create sql views / stored procedure using Entity Framework 4.1 Code first approach

查看:114
本文介绍了您可以使用Entity Framework 4.1代码优先方法创建sql视图/存储过程吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Entity Framework 4.1 Code First可以很好地创建表和关系.是否可以使用代码优先"方法创建sql视图或存储过程?任何与此有关的指针将不胜感激.非常感谢!

Entity Framework 4.1 Code First works great creating tables and relationships. Is it possible to create sql views or stored procedure using Code first approach? Any pointers regarding this will be highly appreciated. Thanks a lot!

推荐答案

EF代码优先方法期望数据库中没有逻辑.这意味着没有存储过程,也没有数据库视图.因此,代码优先方法无法提供任何机制来自动为您生成此类构造.如果这意味着生成逻辑,该怎么办?

EF code-first approach expects that there is no logic in the database. That means no stored procedures and no database views. Because of that code-first approach doesn't provide any mechanism to generate such constructs automatically for you. How could it do that if it means generating logic?

您必须在自定义数据库初始化程序中自行创建它们通过手动执行创建脚本.我认为这种自定义SQL构造不能通过SQL迁移来处理.

You must create them yourselves in custom database initializer by manual executing creation scripts. I don't think that this custom SQL constructs can be handled by SQL migrations.

这篇关于您可以使用Entity Framework 4.1代码优先方法创建sql视图/存储过程吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆