是否可以在App_Data文件夹中保留.dbml(Linq to SQl Classes)文件 [英] Is it possible to keep .dbml(Linq to SQl Classes) file in App_Data folder

查看:71
本文介绍了是否可以在App_Data文件夹中保留.dbml(Linq to SQl Classes)文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





是否可以将.dbml文件保存在App_Data文件夹中。因为我创建了一个MVC4互联网应用程序并在App_Data文件夹中为数据库类创建了一个.dbml文件。

但我没有获得project.i中数据上下文的可见性我无法制作对象数据上下文。请指导我.....

Hi,

Is it possible to keep .dbml file in App_Data folder. Because i created a MVC4 internet application and created a .dbml file in App_Data folder for database classes.
but i am not getting the visibility of the data context in project.i am not able to make the object of data context. Please guide me.....

推荐答案

答案是肯定的,你可以,但它违反了MVC原则。约定规定你将* .dbml放在Model文件夹中。



App_Data文件夹用于数据文件(* .mdf,* xml,* .txt)



如果在添加控制器时没有出现Linq To Sql类,请首先编译Web应用程序 - 然后在编译成功后尝试添加Controller。



如果您仍然发现添加控制器时没有出现System.Data.Linq.DataContext,请使用解决方案资源管理器检查* .designer.cs的文件属性 - 确保构建操作=编译,然后再次重新编译。



只要* .cs文件标有适当的Build Action = Compile,那么代码将包含在Web应用程序中汇编。



干杯,
The answer is yes, you can, but it violates MVC principles. Convention dictates you place the *.dbml in the Model folder.

App_Data folder is for data files (*.mdf, *xml, *.txt)

If your Linq To Sql class do not appear when you add a controller, compile the web application first - then try to add the Controller after successful compilation.

If you still find the System.Data.Linq.DataContext is not appearing when you add a controller, check the file properties for *.designer.cs using Solution Explorer - make sure the Build Action = compile, then recompiled again.

As long as the *.cs files are marked with appropriate Build Action = Compile, then the code will be included in the web app assembly.

Cheers,


这篇关于是否可以在App_Data文件夹中保留.dbml(Linq to SQl Classes)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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