无法更新数据库" *。MDF"因为只读的EntityFramework [英] Failed to update database "*.mdf" because read only EntityFramework

查看:280
本文介绍了无法更新数据库" *。MDF"因为只读的EntityFramework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有实体框架作为DAL一个C#.NET框架4.0的桌面应用程序。 当尝试将数据保存到的DbContext上anybodies机器,但我的,我收到一个异常

 更新数据库失败* .MDF只读
 

我把我的DB附近.exe文件,文件夹DAL / AppData的。

我怎样才能让其他机器上的写访问? 我能做到这一点编程?

我读过,我可以将DB到AppRoaming文件夹,但这不是我的变种。

在此先感谢。

解决方案
  

我把我的DB附近.exe文件,文件夹DAL / AppData的。

是的。它可以是你的意思是,这是在程序文件夹,你懂的。

一,过去10年的窗户规格要说的是对于普通用户只读?

哎唷。

THER是用于存储数据的文件夹。有一个SpecialFolders枚举让每一个这样的文件夹的有效路径。

  

我怎样才能让其他机器上的写访问?我能做到这一点编程?

在一个SQL Server,这是通过允许其它计算机来访问服务器,而不是数据文件来完成。即您连接到SQL Server的另一台机器上,这是有数据库加载。

  

我读过,我可以将DB到AppRoaming文件夹,但这不是我的变种。

首先,这将是愚蠢的,除非你的确需要规划漫游 - SQL shold进入一个本地文件夹中,从来没有漫游

二,不是我的变种就像是嘿,我开车违反规则,我能做些什么不能拿到超​​速罚单。而遵守法律是不是我的变种。你的变体是什么Windows不关心。了解如何根据窗口指导,这是非常明确的地方不断变化的数据不应该安装的软件。

I have a C# .NET Framework 4.0 desktop application with Entity Framework as DAL. When a try to save a data into DBContext on anybodies machine but mine, I recieved an exception

Failed to update database "*.mdf" read only

I keep my DB near .exe file, in folder "DAL/AppData".

How can I allow write access on other machines? Can I do it programmatically?

I've read that I can place DB into AppRoaming Folder, but this is not my variant.

Thanks in advance.

解决方案

I keep my DB near .exe file, in folder "DAL/AppData".

Yes. Can it be you mean that this is in the programs file folder, you know.

THe one that windows specs of the last 10 years say is "read only" for normal users?

OUCH.

THer are folders for storing data. There is a SpecialFolders enumeration to get the valid path of every such folder.

How can I allow write access on other machines? Can I do it programmatically?

On a SQL Server, this is done by allowing the other computer to access the server, not the data files. I.e. you connect to the SQL Server on the other machine, which is having the database loaded.

I've read that I can place DB into AppRoaming Folder, but this is not my variant.

First, that would be stupid unless you do actually plan for roaming - SQL shold go into a local folder, never roaming.

Second, "not my variant" is like "Hey, I drive the car against the rules, what can I do not to get speeding tickets". And "following the law is not my variant". Your variant is something WIndows does not care for. Learn how to install your software according to the windows guideline which is VERY clear where changing data should NOT be.

这篇关于无法更新数据库" *。MDF"因为只读的EntityFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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