entity-framework-core

Owned type property not persisting for a modified entity in EF Core

喜夏-厌秋 提交于 2021-01-22 10:28:37
问题 I'm trying to achieve something in EF Core that worked very well for me in EF 6. I'm serializing the contents of a List<T> property as a Json string in the DB. <T> can be pretty much anything, since Json.Net takes care of serializing whatever we throw at it. My collection exposes a Json string property and takes care of serializing/deserializing itself. This approach is convenient and efficient for structured nested data where a relational model would bring needless overhead and complexity.

Owned type property not persisting for a modified entity in EF Core

你说的曾经没有我的故事 提交于 2021-01-22 10:28:34
问题 I'm trying to achieve something in EF Core that worked very well for me in EF 6. I'm serializing the contents of a List<T> property as a Json string in the DB. <T> can be pretty much anything, since Json.Net takes care of serializing whatever we throw at it. My collection exposes a Json string property and takes care of serializing/deserializing itself. This approach is convenient and efficient for structured nested data where a relational model would bring needless overhead and complexity.

How to add a parent record with its children records in EF Core

一世执手 提交于 2021-01-21 04:25:19
问题 Example 1 below used to work but it is not working in EF Core. Question : How to make example 2 below work? Example 1 : child c1 = new child(); child c2 = new child(); parent p=new parent(); p.child.Add(c1); p.child.Add(c2); using (var db = new DbContext()) { db.parent.Add(p); db.SaveChanges(); } Entity Parent P has children C1, and C2 in a one-to-one relationship. Trying to insert a parent and its children records. But in the following code VS2017 's editor's intellisense does not recognize

Unable to create an object of type '[DBContext's Name]'. For the different patterns supported at design time [closed]

孤人 提交于 2021-01-21 00:34:09
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . Improve this question I'm following one of Mosh Hamedani Course on ASP.NET MVC in Udemy. I came across one error while designing my Database using code-first (Entity Framework). At first, I got the error of " No DbContext was found in assembly" . After resolving this problem

How to handle huge efcore migrations designer files that is slowing down build and IDE

落爺英雄遲暮 提交于 2021-01-20 15:37:39
问题 I currently have an efcore 2.1 project with about 230 entities and about 350 migrations. Every time i add an efcore migration, a designer file is created. This file is approximately 535 kb and growing (150mb total for alle designer files). This makes the IDE slow and unresponsive, refactoring is a no go, it also makes the build process slower. If i delete all designer files, the build goes down from 110 to 20 seconds, and the IDE gets snappy again. however, once I delete all designer files, i

How to handle huge efcore migrations designer files that is slowing down build and IDE

这一生的挚爱 提交于 2021-01-20 15:35:43
问题 I currently have an efcore 2.1 project with about 230 entities and about 350 migrations. Every time i add an efcore migration, a designer file is created. This file is approximately 535 kb and growing (150mb total for alle designer files). This makes the IDE slow and unresponsive, refactoring is a no go, it also makes the build process slower. If i delete all designer files, the build goes down from 110 to 20 seconds, and the IDE gets snappy again. however, once I delete all designer files, i

SQLite in ASP.NET Core with EntityFrameworkCore

谁都会走 提交于 2021-01-20 14:11:45
问题 How do you add and use an SQLite database in an ASP.NET Core web application, using EntityFramework 7 ? I dived into ASP.NET Core the moment I heard about it and created my first web application, I suddenly had a bunch of data that I wanted to store and SQLite seemed like the obvious choice. Since I wanted it to stay with my application, keep it lightweight, simple and avoid setting up a separate database. So how would one go about creating an SQLite database in ASP.NET Core? ASP.NET Core -

Create Direct Navigation Property in EF Core Many to Many Relationship

我是研究僧i 提交于 2021-01-20 12:07:29
问题 I've been working through the following tutorial on how to create a many-to-many relationship using Entity Framework Core: https://docs.microsoft.com/en-us/ef/core/modeling/relationships. I'm working on a group management feature and my models are the following: public class Group { public int GroupId { get; set; } public string GroupName { get; set;} public virtual List<GroupMember> GroupMembers { get; set; } = new List<GroupMember>(); } public class GroupMember { public int GroupId { get;

Create Direct Navigation Property in EF Core Many to Many Relationship

淺唱寂寞╮ 提交于 2021-01-20 12:06:50
问题 I've been working through the following tutorial on how to create a many-to-many relationship using Entity Framework Core: https://docs.microsoft.com/en-us/ef/core/modeling/relationships. I'm working on a group management feature and my models are the following: public class Group { public int GroupId { get; set; } public string GroupName { get; set;} public virtual List<GroupMember> GroupMembers { get; set; } = new List<GroupMember>(); } public class GroupMember { public int GroupId { get;

How to add multiple identity and multiple role in asp.net core

◇◆丶佛笑我妖孽 提交于 2021-01-20 07:52:28
问题 I am new to asp.net core. So this might not be a good question. I have 3 classes: Admin , Doctor , Patient . I want all those users to be able to login and see their dashboard. All of them will have different level of access. So I derived these classes from IdenetityUser like this: public class Admin : IdentityUser { } public class Doctor : IdentityUser { public const int MaxAppointPerDay = 28; public Gender Gender { get; set; } } public class Patient : IdentityUser { public DateTime