草庐IT

ENTITY_SET_NAMES

全部标签

c# - Entity Framework 6 : Code First Cascade delete

所以这里有几个类似的问题,但我仍然无法确定在我的简化场景中到底缺少什么。假设我有以下表格,巧妙地以我自己的名字命名:'JohnsParentTable'(Id,Description)'JohnsChildTable'(Id,JohnsParentTableId,Description)生成的类看起来像这样publicclassJohnsParentTable{publicintId{get;set;}publicstringDescription{get;set;}publicvirtualICollectionJohnsChildTable{get;set;}publicJohns

c# - Entity Framework Core 中的动态更改架构

UPDhere是我解决问题的方法。虽然它可能不是最好的,但它对我有用。我在使用EFCore时遇到问题。我想通过模式机制在我的项目数据库中分离不同公司的数据。我的问题是如何在运行时更改架构名称?我找到了similarquestion关于这个问题,但仍然没有答案,我有一些不同的条件。所以我有Resolve方法在必要时授予db-contextpublicstaticvoidResolve(IServiceCollectionservices){services.AddIdentity().AddEntityFrameworkStores().AddDefaultTokenProviders(

c# - 转换为日期时间 : how to set format

我像这样使用转换:Convert.ToDateTime(value)但我需要将日期转换为类似“mm/yy”的格式。我正在寻找这样的东西:varformat="mm/yy";Convert.ToDateTime(value,format) 最佳答案 您可能应该使用DateTime.ParseExact或DateTime.TryParseExact反而。它们允许您指定特定格式。我个人更喜欢Try版本,因为我认为它们会为错误情况生成更好的代码。 关于c#-转换为日期时间:howtosetfor

c# - 在 Code First Entity Framework (C# ASP.NET MVC 3) 中指定除 dbo 之外的 SQL 用户名

我正在尝试从通过EF(代码优先)连接的ASP.NETMVC3应用程序中的C#连接到共享托管环境中的SQLServer2008数据库。我的问题是生成的SELECT语句如下所示:SELECT...FROM[dbo].[TableName]它会抛出错误Invalidobjectname,但在我这样做时工作正常:SELECT...FROM[mySQLUserName].[TableName]如何指定dbo以外的用户名(例如mySQLUserName)?编辑:我发现与此问题相关的最接近的文章是:http://weblogs.asp.net/scottgu/archive/2010/08/03/u

c# - 如何批量更新 Entity Framework 中的记录?

我正在尝试使用EntityFramework批量更新记录。我试过EntityFramework.ExtensionsUpdate方法。Update方法能够批量更新一组具有相同更新值的记录。例子:Id-QuantityRecord1-A-10Record2-B-20Record3-C-30我们可以通过简单的调用批量更新以上所有记录Records.Update(new=>Record{Quantity=100});如何使用Entityframework.Extensions或任何其他方法批量更新不同数量的每条记录,从而更快地完成批量更新? 最佳答案

c# - 谷歌 Oauth 错误 : At least one client secrets (Installed or Web) should be set

我正在使用Google的Oauth2.0通过我们的服务器将视频上传到Youtube。我的客户ID是一个“服务帐户”。我下载了jsonkey并将其添加到我的解决方案中。相关代码如下:privateasyncTaskRun(stringfilePath){UserCredentialcredential;varkeyUrl=System.Web.HttpContext.Current.Server.MapPath("~/content/oauth_key.json");using(varstream=newFileStream(keyUrl,FileMode.Open,FileAccess

c# - 在 Entity Framework 中显式关闭连接

阅读微软文档http://msdn.microsoft.com/en-us/library/bb738684.aspx我看到他们明确地打开和关闭连接using(EntityConnectionconn=newEntityConnection("name=AdventureWorksEntities")){conn.Open();...conn.Close();}为什么这是必要的? 最佳答案 这不是使用EF的“正常”方式。EF通常会为您管理连接。然而:ManagingConnectionsinObjectServices(Entity

c# - Entity Framework 通过包含对象实现多对多

我很好奇是否可以通过包含对象映射中间表。publicclassSubscriber:IEntity{[Key]publicintId{get;set;}publicstringName{get;set;}privateChannelList_subscribedList{get;set;}publicintNumSubscribedChannels{get{return_subscribedList.Count();}}}publicclassHelpChannel:IEntity{[Key]publicintId{get;set;}publicstringname{get;set;}

c# - 无法删除该对象,因为在 Entity Framework 5 中的 ObjectStateManager 中找不到它

我正在尝试使用EntityFramework5删除对象,但出现此错误。无法删除该对象,因为在ObjectStateManager中找不到它我正在使用Remove()方法,因为EF5中不存在DeleteObject()。任何人都可以帮助我缺少什么吗?这不适用于移除localDb.Customers.Remove(newCustomer(){CustomerId=id});localDb.SaveChanges();我尝试从msdn将状态更改为已删除的另一件事。但是这里它给出了一个错误,说所有的字段都应该存在。是否需要获取完整的记录再删除?varcustomer=newCustomer()

c# - 'GET OR SET ACCESSOR EXPECTED' 是什么意思?

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data;usingSystem.Data.SqlClient;publicpartialclassRepeaterEx2:System.Web.UI.Page{SqlConnectioncn=null;SqlDataAdapterda=null;DataSetds=null;StringstrSqlQuery=