entity-framework

Can't Add ADO.NET Entity Data Model to .NET Core 2.1 Project

梦想的初衷 提交于 2021-02-18 20:11:57
问题 The Issue... As the title states, I've installed the .NET Core 2.1 SDK and created a new .NET Core 2.1 project. When I go to Project > Add Item... > Data , I do not have the ADO.NET Entity Data Model option. I am using Visual Studio 2017 15.7.3 , which I've installed only hours ago. The Error and Warning logs are clean. Any assistance is appreciated. What I've done so far... Researched. You'll notice I've pulled most of my attempts to solve this issue from primarily these three resources:

Can't Add ADO.NET Entity Data Model to .NET Core 2.1 Project

会有一股神秘感。 提交于 2021-02-18 20:05:52
问题 The Issue... As the title states, I've installed the .NET Core 2.1 SDK and created a new .NET Core 2.1 project. When I go to Project > Add Item... > Data , I do not have the ADO.NET Entity Data Model option. I am using Visual Studio 2017 15.7.3 , which I've installed only hours ago. The Error and Warning logs are clean. Any assistance is appreciated. What I've done so far... Researched. You'll notice I've pulled most of my attempts to solve this issue from primarily these three resources:

How to Select All with a One to Many Relationship Using Linq

情到浓时终转凉″ 提交于 2021-02-18 12:57:32
问题 I have two tables: CREATE TABLE Thing ( Id int, Name nvarchar(max) ); CREATE TABLE SubThing ( Id int, Name nvarchar(max), ThingId int (foreign key) ); I want to select all Things with a listing of SubThings and set them to a ThingViewModel. The Thing ViewModel is simple: public class ThingViewModel { public int Id { get; set; } public string Name { get; set; } public List<SubThingViewModel> SubThings { get; set; } } The SubThingViewModel is: public class SubThingViewModel { public int Id {

Do I need to force a Dispose after a LINQ query?

谁说胖子不能爱 提交于 2021-02-18 04:46:51
问题 My DBA says that there are way too many connection open and he thinks it is my code in .net that is leaving them open. I am using LINQ querys and EF code first. Example Method: public List<Stuff> GetStuff() { var db = new DBContext(); var results = db.stuff.toList(); return results; } Do I need to dispose the db var once I am done? My understanding is that I didn't need to in EF and LINQ. Please point me to a Microsoft documentation about managing connection in code or best practices for LINQ

EF Core - adding/updating entity and adding/updating/removing child entities in one request

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-17 21:00:18
问题 I am struggling with what seemed to be a couple of basic operations. Let's say I've got a class named Master: public class Master { public Master() { Children = new List<Child>(); } public int Id { get; set; } public string SomeProperty { get; set; } [ForeignKey("SuperMasterId")] public SuperMaster SuperMaster { get; set; } public int SuperMasterId { get; set; } public ICollection<Child> Children { get; set; } } public class Child { public int Id { get; set; } public string SomeDescription {

Ajax POST to controller action to update view model, and then reload div

百般思念 提交于 2021-02-17 17:09:32
问题 I'm still shaky with my use of ajax so there are a couple holes in my implementation here. I am trying to post to a controller action that will call a stored procedure to update my view model and then reload the div that will display the information. Ajax Post: $("#order-summary-panel").click(function(){ $.ajax({ url: '@Url.Action("GetOrderSummary", "Home")', type: 'POST', success: function() { alert("It Worked!") } }); }); Controller Action: [HttpPost] public ActionResult GetOrderSummary {

Ajax POST to controller action to update view model, and then reload div

吃可爱长大的小学妹 提交于 2021-02-17 17:08:31
问题 I'm still shaky with my use of ajax so there are a couple holes in my implementation here. I am trying to post to a controller action that will call a stored procedure to update my view model and then reload the div that will display the information. Ajax Post: $("#order-summary-panel").click(function(){ $.ajax({ url: '@Url.Action("GetOrderSummary", "Home")', type: 'POST', success: function() { alert("It Worked!") } }); }); Controller Action: [HttpPost] public ActionResult GetOrderSummary {

Get Distinct Entries Based On Specific Column in Entity Framework

感情迁移 提交于 2021-02-17 05:57:21
问题 I have a SQLite table that contains every test result we've run, and I'm looking to write an entity framework query that returns only the most recent test result per project. Normally, I'd assume this would be "group by project id, return row with the max updated value," or, alternatively, "sort by date and return first". However, when I try the query, I keep getting Entity Framework "could not be translated" errors. Here's what I've tried: results = await _context.Results .Include(x => x

Get Distinct Entries Based On Specific Column in Entity Framework

只愿长相守 提交于 2021-02-17 05:57:08
问题 I have a SQLite table that contains every test result we've run, and I'm looking to write an entity framework query that returns only the most recent test result per project. Normally, I'd assume this would be "group by project id, return row with the max updated value," or, alternatively, "sort by date and return first". However, when I try the query, I keep getting Entity Framework "could not be translated" errors. Here's what I've tried: results = await _context.Results .Include(x => x

EF Core Many-to-Many self join

吃可爱长大的小学妹 提交于 2021-02-16 21:04:57
问题 I am trying to describe a many-to-many self-referential relationship to Entity Framework Core 2. Essentially what I'm trying to model is a sort of tree structure, in which each element can have an arbitrary number of parent and child elements (so I guess more a graph than a tree). Here's what I have so far: public class OrgLevel { ... public ICollection<OrgLevelOrgLevels> OrgLevelOrgLevelsAsParent { get; set; } public ICollection<OrgLevelOrgLevels> OrgLevelOrgLevelsAsChild { get; set; }