草庐IT

H2Database

全部标签

c# - EntityFramework 测试初始化​​错误 : CREATE DATABASE statement not allowed within multi-statement transaction

我正在尝试构建一个快速测试,每次运行时都会删除并重新创建数据库。我有以下内容:[TestClass]publicclassPocoTest{privateTransactionScope_transactionScope;privateProjectDataSource_dataSource;privateRepository_repository=newRepository();privateconststring_cstring="DataSource=.;InitialCatalog=test_db;Trusted_Connection=True";[TestInitialize

c# - 在 "CREATE TABLE permission denied in database"ASP.NET - MVC4 中列出表结果

我正在使用ASP.NETMVC4-c#连接到实时数据库并列出结果,但是当我查看页面时它返回以下错误:CREATETABLEpermissiondeniedindatabase'DatabaseName'.Description:Anunhandledexceptionoccurredduringtheexecutionofthecurrentwebrequest.Pleasereviewthestacktraceformoreinformationabouttheerrorandwhereitoriginatedinthecode.ExceptionDetails:System.Dat

c# - EF 5 代码迁移错误 : "There is already an object named _____ in the database"

在进行EF5代码迁移时遇到了一个反复出现的奇怪问题,现在让我无法工作。尝试运行update-database并收到此错误:Thereisalreadyanobjectnamed'RequestStatus'inthedatabase.详细的日志转储:PM>update-database-vUsingStartUpproject'LicensingWorkflow'.UsingNuGetproject'LicensingWorkflow'.Specifythe'-Verbose'flagtoviewtheSQLstatementsbeingappliedtothetargetdataba

c# - 无法使用 EFCore、EntityState.Modified : "Database operation expected to affect 1 row(s) but actually affected 0 row(s)." 编辑数据库条目

我将IdentityCore1.0与ASP.NETMVCCore1.0和EntityFrameworkCore1.0结合使用来创建一个简单的用户注册系统thisarticle作为起点,我正在尝试添加用户角色。我可以添加用户角色,但无法编辑它们。这是RolesController中的Edit操作:[HttpPost][ValidateAntiForgeryToken]publicIActionResultEdit(IdentityRolerole){try{_db.Roles.Attach(role);_db.Entry(role).State=Microsoft.EntityFrame

c# - "Data Source cannot be empty. Use :memory: to open an in-memory database"是什么意思?

我最近将我的SQLServer数据库转换为SQLite数据库。但是当我尝试使用.Open()打开我的SQLite时,它​​抛出了这个错误:DataSourcecannotbeempty.Use:memory:toopenanin-memorydatabase编辑:添加连接字符串:ConnectionString=@"DataSource=D:\XXX.db;Version=3";connection=newSQLiteConnection(connectionString);connection.Open();为什么我会得到这个?我将相同的SQLServer数据库转换为SQLCE和my

C# (Visual studio) : Correlation between database, 数据集,绑定(bind)源

我只是通过VisualStudio2008学习C#?我想知道数据库、数据集和绑定(bind)源之间到底有什么关联?还有,表格适配器的作用是什么? 最佳答案 超高水平:数据库——存储原始数据DataSet--一个.NET对象,可用于读取、插入、更新和删除数据库中的数据BindingSource--一个.NET对象,可用于控件的数据绑定(bind)。BindingSource可以指向数据集,在这种情况下控件将显示和编辑该数据TableAdapter--将数据库表中的数据映射到DataSet中所有这些还有很多,了解ADO.NET的架构方式

c# - 必须使用 dbcontext.Database.SqlQuery 声明标量变量 '@custid'?

我正在尝试使用EF5从bcontext.Database.SqlQuery执行存储过程。它抛出错误必须声明标量变量“@custid”varresults=_MiscContext.Database.SqlQuery("execsp_GetStaff@custid",customerNumber).ToList();如果customerNumber是员工,SP返回1否则返回空行。ALTERPROCEDURE[dbo].[sp_GetStaff]@custidvarchar(12)ASBEGINSETNOCOUNTON;SELECT1AS[C1]FROM[dbo].[Staff]with(

c# - Entity Framework 代码首先更新数据库在 CREATE DATABASE 上失败

ThisposthasbeennotedSohasthisone在我的开发机器上,我正在尝试使用包管理器控制台中的更新数据库重新创建我的数据库。我相信我已按照上述帖子中的说明进行操作。我收到此错误消息:Afileactivationerroroccurred.Thephysicalfilename'\WRDatabase.mdf'maybeincorrect.Diagnoseandcorrectadditionalerrors,andretrytheoperation.CREATEDATABASEfailed.Somefilenameslistedcouldnotbecreated.C

javascript - 我怎样才能使 jQuery 直接转到 <h2 id ="id-name">?

我想让jQuery直接(不需要动画)导航到我传入变量的id。我有各种标记,例如id="content",id="edit",id="..."那是标题。使用PHP进行验证时,我将输出一个类似varNAVIGATE_TO=的变量我想把网站移到那个id位置。就像我做的那样domain.tld/page#edit或#content但是使用jQuery是因为当我加载页面时,我的PHP框架不允许我指示哈希值。 最佳答案 你可以设置location.hash到id你需要浏览器滚动到:window.location.hash='#edit';

php - 建议 : building a non-database driven simple CMS in PHP

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭8年前。Improvethisquestion我在一个需要非常简单的CMS的网站上工作-主页上基本上有一段文本需要客户进行编辑。他们当前的托管计划不允许使用数据库,包括一个数据库每月要额外花费X美元,我认为对于这样一个基本系统来说这是不必要的。该站点目前是使用Codeignitor构建的。我打算使用平面PHP或TXT文件来编写它的CMS部分,有没有值得考虑的替代方法,优点/缺点是什么?