ef-core-2.2

EF Core always create .Annotation(“SqlServer:Identity”, “1, 1”) on add-migration

主宰稳场 提交于 2021-02-11 06:16:33
问题 I'm having a problem with Migration EF Core. To make the scenario clear, I'm assigning it to an existing database, which is intended to use migration for database control from now on. But I am having difficulties. What I have done so far. I generated the scaffolding from the existing database. I added the migration, so it generated all the "Up" for database creation. In a clean database, ran update-database. So far perfect, everything worked as expected. But from this step every time I

EF Core always create .Annotation(“SqlServer:Identity”, “1, 1”) on add-migration

不打扰是莪最后的温柔 提交于 2021-02-11 06:10:20
问题 I'm having a problem with Migration EF Core. To make the scenario clear, I'm assigning it to an existing database, which is intended to use migration for database control from now on. But I am having difficulties. What I have done so far. I generated the scaffolding from the existing database. I added the migration, so it generated all the "Up" for database creation. In a clean database, ran update-database. So far perfect, everything worked as expected. But from this step every time I

Microsoft SQL Server foreign key dependencies show up using sp_MSdependencies but are not listed in sys.foreign_keys

最后都变了- 提交于 2021-01-29 06:21:04
问题 I have a table that when I click view dependencies, it shows less related tables than if I run the following T-SQL EXEC sp_MSdependencies N'Item.Item', null, 1315327 There are three dependencies for three different tables that don't show up in the GUI. This wouldn't really be an issue for me but EFCorePowerTools is also not mapping those dependencies. So my question is - does anyone know what the Microsoft SSMS tool is using to visually show the dependencies when you right click and choose

How to make a middleware that can call database to check user claims to authorize a user in asp.net core 2.2

会有一股神秘感。 提交于 2021-01-29 05:30:58
问题 What is the best practice to make a middleware or a proper way to implement middleware in asp.net core 2.2. My Scenario is I have a web api build in asp.net core 2.2 and I implement authorization in my controller something like this [Authorize(Policy = "UserDelete")] UserDelete is a user claim my problem is i have many user claim can user have, more or less up to 20 claims if I save this claims in JWT it can cause large size of JWT all i want to do is to call claims or create a middleware

How to reload collection in EF Core 2.x?

半腔热情 提交于 2021-01-27 10:51:59
问题 I know there is a Load method. _dbContext.Entry(blog).Collection(b => b.Posts).Load() But I'm try to handle concurrency conflicts, I've been add a post into blog.Posts . if call Load , it do not clear the blog.Posts , just append the existing Posts to it. I had try: blog.Posts = null; _dbContext.Entry(blog).Collection(b => b.Posts).Load() But blog.Posts become a empty collection (Zero Count). So I want a Reload . 回答1: Unfortunately although EntityEntry has Reload method, there is no such

Entity Framework Core 2.2 : Disable migrations for specific entities

拥有回忆 提交于 2020-12-08 13:41:29
问题 I'm trying to build an aspnetcore application over an existing system where the database is already created, and I'm going to add some tables over it. I've reverse engineered the database to add the existing tables as entities to my application, and I've written my own entities that will be added later. Finally, all the entities are added to a single DbContext. My requirement comes as follows: I want to enable code first migrations for the newly added entities I don't want the migrations to

Entity Framework Core 2.2 : Disable migrations for specific entities

╄→尐↘猪︶ㄣ 提交于 2020-12-08 13:32:28
问题 I'm trying to build an aspnetcore application over an existing system where the database is already created, and I'm going to add some tables over it. I've reverse engineered the database to add the existing tables as entities to my application, and I've written my own entities that will be added later. Finally, all the entities are added to a single DbContext. My requirement comes as follows: I want to enable code first migrations for the newly added entities I don't want the migrations to

Entity Framework Core 2.2 : Disable migrations for specific entities

99封情书 提交于 2020-12-08 13:30:49
问题 I'm trying to build an aspnetcore application over an existing system where the database is already created, and I'm going to add some tables over it. I've reverse engineered the database to add the existing tables as entities to my application, and I've written my own entities that will be added later. Finally, all the entities are added to a single DbContext. My requirement comes as follows: I want to enable code first migrations for the newly added entities I don't want the migrations to