entity-framework-core

Entity Framework Core hierarchyid

℡╲_俬逩灬. 提交于 2020-07-18 10:15:07
问题 I'm trying to use EF Core but I need to use the sql server datatype hierarchyid on one of my tables. Is it possible to designate a field in my c# class to be of type hierarchyid? Could I manually column EF creates to be type hierarchyid without breaking EF? Edit: I have tried to do this: public class Entity { public int Id { get; set; } public string Name { get; set; } public SqlHierarchyId HierarchyId { get; set; } } As it's suggested that this is supported by EF core 2.1, however when i run

IDbAsyncQueryProvider in EntityFrameworkCore

自古美人都是妖i 提交于 2020-07-18 09:15:11
问题 I'm using XUNIT to test in a dot net core application. I need to test a service that is internally making an async query on a DbSet in my datacontext. I've seen here that mocking that DbSet asynchronously is possible. The problem I'm having is that the IDbAsyncQueryProvider does not seem to be available in EntityframeworkCore, which I'm using. Am I incorrect here? Has anyone else got this working? (Been a long day, hopefully I'm just missing something simple) EDIT After asking on GitHub, I

How do you avoid the EF Core 3.0 “Restricted client evaluation” error when trying to order data from a one-to-many join?

馋奶兔 提交于 2020-07-16 08:22:24
问题 I have a table I'm displaying in a site which is pulling data from a few different SQL tables. For reference, I'm following this guide to set up a sortable table. Simplify the model, say I have a main class called "Data" which looks like this (while the Quotes class stores the DataID): namespace MyProject.Models { public class Data { public int Id { get; set; } public string Name { get; set; } public int LocationId { get; set; } public Models.Location Location { get; set; } public IList

Is it possible to use MVVM Light with Entity Framework Core in a UWP project?

一世执手 提交于 2020-07-10 10:25:40
问题 I'm trying to use Entity Framework Core with UWP. I found this sample from Microsoft and got it to work. In this sample, the object models are in a .Net Standard class library. However, for the project I'm working on, I need to be able to use MVVM Light's RaisePropertyChanged method in the setters of my object models. The issue I'm running into is that MVVM Light is apparently not compatible with .NET Standard 2.0, only 1.0. MVVM Light does seem to install correctly to the class library, but

Is it possible to use MVVM Light with Entity Framework Core in a UWP project?

筅森魡賤 提交于 2020-07-10 10:25:06
问题 I'm trying to use Entity Framework Core with UWP. I found this sample from Microsoft and got it to work. In this sample, the object models are in a .Net Standard class library. However, for the project I'm working on, I need to be able to use MVVM Light's RaisePropertyChanged method in the setters of my object models. The issue I'm running into is that MVVM Light is apparently not compatible with .NET Standard 2.0, only 1.0. MVVM Light does seem to install correctly to the class library, but

Is it possible to use MVVM Light with Entity Framework Core in a UWP project?

吃可爱长大的小学妹 提交于 2020-07-10 10:24:50
问题 I'm trying to use Entity Framework Core with UWP. I found this sample from Microsoft and got it to work. In this sample, the object models are in a .Net Standard class library. However, for the project I'm working on, I need to be able to use MVVM Light's RaisePropertyChanged method in the setters of my object models. The issue I'm running into is that MVVM Light is apparently not compatible with .NET Standard 2.0, only 1.0. MVVM Light does seem to install correctly to the class library, but

EntityFramework Core production migrations

人走茶凉 提交于 2020-07-10 05:40:34
问题 How do I update the database for production? I've moved the connection string secrets out of the application. Our CI/CD pipeline handles the token replacement within the connection string "template" that remains in the appsettings, and developers won't have production database access. I had expected to use automatic migrations, only to discover today that Microsoft eliminated that for EF Core. Will I have to, every time, temporarily overwrite the connection string that normally specifies my

EntityFramework Core production migrations

痴心易碎 提交于 2020-07-10 05:38:33
问题 How do I update the database for production? I've moved the connection string secrets out of the application. Our CI/CD pipeline handles the token replacement within the connection string "template" that remains in the appsettings, and developers won't have production database access. I had expected to use automatic migrations, only to discover today that Microsoft eliminated that for EF Core. Will I have to, every time, temporarily overwrite the connection string that normally specifies my

EF Core migration error: Object reference not set to an instance of an object

感情迁移 提交于 2020-07-09 12:22:10
问题 Earlier, add migrations was not working for me since the migration and dbcontext were in different assemblies. After I move both of them inside the same assembly, that error doesn't occur anymore, instead, I am getting this new error. Since there is not much information other than the stack trace, I am unable to find where the problem is. Command: dotnet-ef migrations add identity Stack trace: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft

How to use the optionsBuilder.UseNpgsql with multiple connection strings?

南笙酒味 提交于 2020-07-09 12:13:10
问题 I am trying to do an update-database in the Package Manager Console with multiple connection strings that are stored in a list of strings called lDataBaseConnection It works fine if I specify which index in my list of strings and simply run the update-database in the Package Manager Console. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseNpgsql(this.lDataBaseConnection[0]); } But if I use a loop, instead of updating all the databases... I