entity-framework

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

Can we Scaffold DbContext from selected tables of an existing database

可紊 提交于 2021-01-20 15:23:35
问题 As in previous versions of Entity Framework, is it possible in Entity Framework Core to reverse engineer only the selected tables of an existing database to create model classes out of them. This official ASP.NET site reverse engineers the entire database. In past, as shown in this ASP.NET tutorial, using old EF you could reverse engineer only the selected tables/Views if you chose to. 回答1: One can solve the problem by usage of dotnet ef dbcontext scaffold command with multiple -t ( --table )

Can we Scaffold DbContext from selected tables of an existing database

纵饮孤独 提交于 2021-01-20 15:22:28
问题 As in previous versions of Entity Framework, is it possible in Entity Framework Core to reverse engineer only the selected tables of an existing database to create model classes out of them. This official ASP.NET site reverse engineers the entire database. In past, as shown in this ASP.NET tutorial, using old EF you could reverse engineer only the selected tables/Views if you chose to. 回答1: One can solve the problem by usage of dotnet ef dbcontext scaffold command with multiple -t ( --table )

How to add foreign key in sql server [closed]

独自空忆成欢 提交于 2021-01-20 13:33:10
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 days ago . Improve this question I have Types column in my Help Table and I want to add foreign key to the Id column in my HelpType table but not really sure what I'm doing wrong so. If I can get any suggestion or help will be really appreciated. ALTER TABLE Help ADD CONSTRAINT FK_Types FOREIGN KEY (Types)

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

EF Core DB First, and how to avoid Constructor Overwrite on Model Generation

↘锁芯ラ 提交于 2021-01-19 06:23:20
问题 I am moving away from using SQL Authentication with my Azure DB, to Active Directory Managed Authentication as explained in this article. Basically, I'm doing two main things to get this working. 1- injecting the token in the DBContext constructor: public MyDBContext(DbContextOptions<MyDBContext> options) : base(options) { var conn = (SqlConnection)Database.GetDbConnection(); conn.AccessToken = (new Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider()).GetAccessTokenAsync(

How to map a column name with spaces in it to a POCO property?

a 夏天 提交于 2021-01-18 05:49:02
问题 I am working on database table which has a column name with a space in it, for example "Level Description". I cannot change the column name. Now I have an Entity Framework model class for this table and the compiler is complaining about this property, because property names can't contain spaces! How can I define the column with space in my class? [Table("StudyLevel")] public class StudyLevelModel { [Key] public byte StudyLevelID { get; set; } // How to map this to the column "Level