entity-framework-core

Entity Framework Core support for SQL Spatial Data Types - DBGeography?

此生再无相见时 提交于 2019-12-23 09:35:28
问题 I want to make a web application using ASP.NET Core Razor Pages that has some geographic data in SQL Server. Visual Studio gives an error that it doesn't support the Geography data type when creating the EF model using EF Core from an existing SQL DB. Is there a way to use SQL Spatial Data Types like Geography in an ASP.NET Core project using Entity Framework or EF Core? This link shows some workarounds but nothing out of the box. This link is an older post dealing with this question. 回答1:

Entity Framework Core Database-First Update after initial Scaffold?

自作多情 提交于 2019-12-23 07:17:06
问题 I'm playing around with Entity Framework Core and I have been working on implementing a Database-First application. The initial Scaffold-DbContext command works just fine and creates all my entities correctly, if not organized as I would like. It's a SQL Server database that uses schemas to break up areas of responsibility and I don't really care for the fact that the Scaffold just throws them all into a single folder. That aside, I have been unable to determine if there is a way to re-run

One-to-one relationship with EFCore 2.1

风流意气都作罢 提交于 2019-12-23 05:35:16
问题 The following code was working with EFCore 2.0. Since the 2.1 update, I get a blocking bug: The child/dependent side could not be determined for the one-to-one relationship between 'Entity2.Main' and 'Entity1.Metadata'. To identify the child/dependent side of the relationship, configure the foreign key property. If these navigations should not be part of the same relationship configure them without specifying the inverse. See http://go.microsoft.com/fwlink/?LinkId=724062 for more details. The

.NET Core 2.1 Identity : Creating a table for each Role + bridge M:M table

北城以北 提交于 2019-12-23 03:15:19
问题 I'm having issues in figuring out the best design that fits my needs regarding a Role based authorizations using Identity in a .NET Core 2.1 project. I already extended the User class from Identity with an ApplicationUser class. I need 5 different roles to control the access to the different features of the app : Admin, Teacher, Student, Parent and Supervisor All the common attributes are kept in User and ApplicationUser but I still require different relationships to other tables depending of

.NET Core 2.1 Identity : Creating a table for each Role + bridge M:M table

主宰稳场 提交于 2019-12-23 03:15:03
问题 I'm having issues in figuring out the best design that fits my needs regarding a Role based authorizations using Identity in a .NET Core 2.1 project. I already extended the User class from Identity with an ApplicationUser class. I need 5 different roles to control the access to the different features of the app : Admin, Teacher, Student, Parent and Supervisor All the common attributes are kept in User and ApplicationUser but I still require different relationships to other tables depending of

Has EF6+ / 7 added any ways that I can add update child tables?

故事扮演 提交于 2019-12-23 01:59:09
问题 I have two tables: public AdminTest() { this.AdminTestQuestions = new List<AdminTestQuestion>(); } public int AdminTestId { get; set; } public string Title { get; set; } public virtual ICollection<AdminTestQuestion> AdminTestQuestions { get; set; } } public partial class AdminTestQuestion { public int AdminTestQuestionId { get; set; } public int AdminTestId { get; set; } public System.Guid QuestionUId { get; set; } public virtual AdminTest AdminTest { get; set; } } I am using the following

EF Core: Using ID as Primary key and foreign key at same time

谁说胖子不能爱 提交于 2019-12-23 00:26:36
问题 I have two entites, Prospect and person, what I'm trying to do is use Prospect.ID as primary key on ProspectTable and as foreignkey of PersonID, my ideia is use the same ID for both entities without the need of a PersonID on my Prospect entity. When the prospect is being saved on database, it tries to save a PersonID even I not have this property on my Prospect entity, I would like to know if ef core supports this kind of relationship. Here's what I got on my model builder. modelBuilder

UserManager throws exception - Unable to track an entity because primary key property 'Id' is null - after upgrading from .Net Core 2.2 to 3.0

旧城冷巷雨未停 提交于 2019-12-22 14:52:37
问题 I've used the custom implementation of User which is derivated from IdentityUser using Asp.Net Core Identity : public class AppUser : IdentityUser { ... } If I call the method: var identityResult = await UserManager.CreateAsync(user); I get the error: System.InvalidOperationException: Unable to track an entity of type 'AppUser' because primary key property 'Id' is null. It works perfectly with version of Microsoft.AspNetCore.Identity.EntityFrameworkCore - 2.2.0 , but after upgrading to 3.0.0

How to deal with database changes during development with EF Core?

ぐ巨炮叔叔 提交于 2019-12-22 10:56:02
问题 I am struggling with database changes during development with .NET Core and Entity Framework Core. When I create new model and add it to dbContext, even with dbContext.Database.EnsureCreated(); in Startup.cs it does not create new tables. It will create all tables only if I will do dotnet ef database drop before, but it is pretty annoying to have to seed db every time adding new model. creating more and more migration every time does not look like good idea to me... Can someone suggest better

EF Core 2.1 In memory DB not updating records

☆樱花仙子☆ 提交于 2019-12-22 10:44:38
问题 I'm using the in memory database provider for integration tests however I don't seem to be able to update a record. I've run the same code against a real SQL database and everything gets updated fine. Here is my test fixture code. Test Fixture: public class TestFixture<TStartup> : IDisposable { private readonly TestServer _testServer; public HttpClient TestClient { get; } public IDatabaseService DbContext { get { return _testServer.Host.Services.GetService<DatabaseService>(); } } public