可以“不将我的数据库放在“App_Data”下吗?影响 Linq2Sql 的工作方式?

发布于 2024-08-12 09:55:25 字数 306 浏览 3 评论 0原文

我在处理所有项目时遇到问题。我无法使用 Linq2Sql 获得 Intellisense,并且当我在模型文件夹中编写部分类时,部分类无法识别由 Linq2Sql 设计器创建的属性。因此,我试图排除问题的所有可能根源。

我有两种情况:(i) 在 App_Data 下创建一个 .mdf 文件,(2) 在 SQL EXPRESS 2005 中创建一个 .dbo 文件。现在,当我创建 DataContext 时文件(通过在设计器中拖放表格),是否会以相同的方式工作?或者我需要预料到意外的行为吗?

谢谢

I'm experiencing a problem while working with all my projects. I don't get Intellisense with Linq2Sql and, when I write partial classes in the model folder, properties created by the Linq2Sql designer are not recognized by the partial classes. So, I'm trying to rule out all the possible sources of the problem.

I have 2 cases: (i) create a .mdf file under App_Data and (2) create a .dbo file in SQL EXPRESS 2005. Now, when I create the DataContext file (by dragging and dropping tables in the designer), are there going to work the same way? Or do I need to expect unanticipated behavior?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

表情可笑 2024-08-19 09:55:25

App_Data 仅在 ASP.NET 应用程序中使用,并且仅用于存储物理数据库文件(ASP.NET 工作进程始终具有对该文件夹的读/写访问权限)。对于常规应用程序,您应该将任何数据库文件放置在每个人都有权访问的公共位置(或每个正在使用该应用程序的人)。

将您的 DBMLlinq to sql 类 文件)放在项目的子文件夹中,该子文件夹相对于命名空间有意义。例如,您可以将其放在 MyApp/Data 或 MyApp/Repository 或 MyApp/Models 等下。

.dbml 设计器 中,检查属性工具窗口并确保指定名称和命名空间对于数据上下文和实体。您的实体部分类必须位于相同的命名空间中,否则编译器将不知道将它们放在一起。

App_Data is only used in ASP.NET apps and is only meant to store the physical database file (the ASP.NET worker process always has read/write access to that folder). For regular apps you should be dropping any database file in common locations that everyone has rights to (or everyone who is using the app).

Put your DBML (linq to sql classes file) in the subfolder of your project where it makes sense vis a vis the namespace. For instance, you'd put it under MyApp/Data or MyApp/Repository or MyApp/Models, etc.

In the .dbml designer, check the properties tool window and make sure you specify the name and namespace for the data context and the entities. Your entity partial classes MUST be in the SAME namespace or the compiler won't know to put them together.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文