草庐IT

dynamic-frameworks

全部标签

c# - 如何使用 Entity Framework Core 可视化设计我的数据库?

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭5年前。社区在1年前审查了是否重新打开这个问题,然后将其关闭:原始关闭原因未解决Improvethisquestion我在想,我应该如何设计我的数据库方案(在效率和可视化方面)。我正在使用Angular2开发ASP.NETCore应用程序,我正在使用EntityFrameworkCore("Microsoft.EntityFrameworkCore":"1.0.0"),因为它是我最喜欢的ORM。我绝对更喜欢SQL

c# - List<Task> - 使用 C# Entity Framework 的 UPSERT 数据库记录

我有一个Employee对象,我正在尝试使用单个DB实体上下文使用多个任务(并行执行)来更新记录(即更新/删除)。但是我收到以下异常Message="Objectreferencenotsettoaninstanceofanobject."考虑以下DTOpublicclassEmployee{publicintEmployeeId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicListContactPhoneNumbers{get;set;}publicListContactEma

c# - Entity Framework 5 Remove() 不从数据库中删除

我有一个用户对象,当使用DbContext上的Remove()删除它时,它并没有从数据库中删除。奇怪的是,我检索用户的查询不再返回它。此代码在我的应用程序中使用,并且可以毫无问题地用于其他实体。我真的很感激关于这可能是什么的建议,因为我很困惑!#regionDeletepublicvirtualvoidDelete(Userentity){varuser=_context.Users.FirstOrDefault(u=>u.UserId==entity.UserId);if(user!=null){user.Roles.Clear();varactionHistories=_conte

c# - .NET Core Entity Framework - 为类库中的 Context 添加迁移

我在将初始迁移添加到.NETCore类库中的EntityFramework数据库上下文时遇到问题。当我运行时:dotnetefmigrationsaddmigrationName-cPlaceholderContext我得到错误:Couldnotinvokethiscommandonthestartupproject'Placeholder.Data'.ThisversionoftheEntityFrameworkCore.NETCommandLineToolsdoesnotsupportcommandsonclasslibraryprojectsinASP.NETCoreand.NE

c# - 在 Entity Framework 4 中处理对象上下文

我有一个实体类,它是从我的数据库模型自动生成的。该类继承了ObjectContext,后者又继承了IDisposable。我创建了一个存储库,其中包含各种方法,这些方法使用实体对象的单个实例与数据库进行交互。自动生成类publicpartialclassDevEntities:ObjectContext{publicconststringConnectionString="name=DevEntities";publicconststringContainerName="DevEntities";存储库类DevEntitiesdb=newDevEntities();publicCust

c# - .NET Framework 4.6.2 类库中的目标 .NET Core 类库

我有一个使用.NETCore编写的库,目标是.netstandard2.0。根据这个site.NETCore库的那个版本应该与.NET4.6.2和4.6.1兼容。但是,当我尝试构建我的.NETFramework库时,出现此错误:Project'c:\myproj.csproj'targets'.NETStandard,Version=v2.0'.Itcannotbereferencedbyaprojectthattargets'.NETFramework,Version=v4.6.2'.我正在使用VisualStudio2017构建库。我正在做的事情是不可能的/不支持的,我只是在误解网

c# - Entity Framework : mapping tinyint to boolean

EntityFramework默认将tinyint映射到byte。我尝试将生成的基础类型更改为bool值,但出现编译错误指定的成员映射无效。成员blah的类型'Edm.Boolean[Nullable=False,DefaultValue=]'...这在4.0中可能吗?将tinyint列用作bool值不是我的主意。这是由另一个使用hibernate的团队自动完成的,显然这样做是为了与mysql兼容。显然tinyint的值比2多。我正在寻找一种方法来映射它,以便任何接受1的东西都是假的,或者任何接受0的东西都是真的。要么对我有用有没有办法将某种类型的转换器插入到EF中?

c# - Entity Framework 4 中的简单条件 LINQ 查询

我最近将这段代码迁移到了EntityFramework4,但失败了。显然,如果status没有值,则返回所有匹配项,如果它有值匹配user.StatusID==1。returnusers.SingleOrDefault(user=>user.Username==username&&user.EncryptedPassword==password&&(!status.HasValue||user.StatusID==1));异常返回:ArgumentException:Thespecifiedvalueisnotaninstanceoftype'Edm.Int32'Parameterna

c# - 如何在 Entity Framework 代码优先方法中映射自身的递归关系

我想要创建的只是基本的递归类别。如果RootCategory_Id设置为null,则类别为根;如果设置为某个id,则它属于其他某个类别。我在Seed()方法中添加了带有两个子类别的类别进行测试,但它不起作用。(后来查了DB,有插入)类别模型publicclassCategory{publicintID{get;set;}publicCategoryRootCategory{get;set;}//Thisoneworksgood,italsocreates"RootCategory_Id"indatabaseon"update-database"publicICollectionChil

c# - Entity Framework Code First - 两个名称相同但 namespace 不同的实体

我在以下情况下遇到数据库生成问题:1.csFirst.Entities命名空间中的项目实体映射到First_Project表。namespaceFirst.Entities{#regionusingsectionusingSystem.Collections.Generic;usingSystem.ComponentModel.DataAnnotations;usingSystem.Data.Entity.ModelConfiguration;usingSystem.Diagnostics.CodeAnalysis;#endregion[Table("First_Project")]p