ef-core-3.0

Xamarin Forms, Sqlite, EF Core 3, migrations, and lot of confussion

孤街醉人 提交于 2021-02-18 07:56:25
问题 I have a Xamarin Forms app that I have switched from using only restful API to using local SQLite DB, that will sync using this Dotmim.Sync - DB Sync'ing Framework (which is great!). I am using EF Core 3 in the Xamarin forms project to interact with SQLite. My questions are around running migrations or just database updates on SQLite. I have read several blogs and forums about different approaches, but they all are several years old, from EF Core 1 to EF Core 2, and lots of work around. https

EF Core LINQ query failing due to limitation?

孤人 提交于 2021-02-11 13:52:45
问题 I am trying to do quite a simple group by, and sum, with EF Core 3.0 However am getting a strange error: System.InvalidOperationException: 'Processing of the LINQ expression 'AsQueryable((Unhandled parameter: y).TransactionLines)' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. var creditBalances = await context.Transaction .Include(x => x.TransactionLines) .Include(x=>x.CreditAccount) .Where(x => x.CreditAccount.UserAccount.Id ==

How to solve 'Cannot authenticate using Kerberos' issue doing EF Core database scaffolding in Linux(Ubuntu 18.04)? Are there any solutions?

走远了吗. 提交于 2021-02-09 01:47:28
问题 everyone. I've been trying to develop simple starting AspNetCore application with EntityFrameworkCore to connect and work with MS SQL server database. And manage all this by Rider IDE, tool for Database client(DBeaver) and dotnet command line interface(dotnet ef). I'm using database first approach(create database on mssql server, fill it with tables and then build Models based on tables). My STEP-by-STEP actions: 1)install and set up mssql server for my machine working on Ubuntu 18.04.

How to solve 'Cannot authenticate using Kerberos' issue doing EF Core database scaffolding in Linux(Ubuntu 18.04)? Are there any solutions?

自闭症网瘾萝莉.ら 提交于 2021-02-09 01:43:29
问题 everyone. I've been trying to develop simple starting AspNetCore application with EntityFrameworkCore to connect and work with MS SQL server database. And manage all this by Rider IDE, tool for Database client(DBeaver) and dotnet command line interface(dotnet ef). I'm using database first approach(create database on mssql server, fill it with tables and then build Models based on tables). My STEP-by-STEP actions: 1)install and set up mssql server for my machine working on Ubuntu 18.04.

Is a DbSet required to run a stored procedure?

两盒软妹~` 提交于 2021-01-29 18:34:59
问题 I have a stored procedure that returns data from a multi-table query. To do this do I need to create a DbSet for each of the tables that are involved in the query? All the examples I find that use FromSql have a DbSet (e.g., Books in the below example) specified before the FromSql clause. using (var context = new SampleContext()) { var books = context.Books .FromSql("EXEC GetAllBooks") .ToList(); } My understanding is a DbSet represents an table. Note that I am working against an existing DB

How to Create Migration on Runtime in Entity Framework Core

送分小仙女□ 提交于 2021-01-29 16:07:08
问题 Is there any possible way to create migration on runtime in efcore. context.Database.Migrate(); Before this code, I need a code that, when I started my app, should create a migration about diff between postgresql database tables and ef models. Is there any way to do this? PM> enable-migrations PM> add-migration initial PM> update-database I dont want to use these ones. I want to make these code's jobs on runtime. I hope I could explain myself clearly. 回答1: Note, you need to re-compile the app

What is required for EF Core's IMethodCallTranslator to work with `EF.Functions` to provide a custom function?

天涯浪子 提交于 2021-01-29 13:28:59
问题 I'm trying to implement a custom IMethodCallTranslator in EF Core 3.1 with the Sqlite provider. I have created: An extension method off of this DbFunctions which is called at query time An implementation of IMethodCallTranslator which is Translate not called A derived RelationalMethodCallTranslatorProvider which I'm passing an instance of my IMethodCallTranslator . This constructor is hit. I also tried overriding RelationalMethodCallTranslatorProvider.Translate and this was not hit. An

Is a DbSet required to run a stored procedure?

南楼画角 提交于 2021-01-29 11:06:05
问题 I have a stored procedure that returns data from a multi-table query. To do this do I need to create a DbSet for each of the tables that are involved in the query? All the examples I find that use FromSql have a DbSet (e.g., Books in the below example) specified before the FromSql clause. using (var context = new SampleContext()) { var books = context.Books .FromSql("EXEC GetAllBooks") .ToList(); } My understanding is a DbSet represents an table. Note that I am working against an existing DB

Create Dbcontext at run-time

冷暖自知 提交于 2021-01-29 05:13:24
问题 I have a requirement to switch to a different data sources at runtime. sometimes user wants to connect to a different database server to manipulate data. There can be more than 100 client servers with an identical database. Original project is a .net core Web API and the server name is an input parameter. This is what I thought. Is there a better alternative? public class Person { public int Id { get; set; } public string Name { get; set; } } public class MyDbContext : DbContext { public

what's the best solution for Many to Many Relation in .Net Core(EF Core)? [duplicate]

江枫思渺然 提交于 2021-01-28 05:16:46
问题 This question already has an answer here : Entity Framework Core many-to-many navigation issues (1 answer) Closed 10 months ago . as you know we don't have automatic Many to Many Relations between Entities in EF Core. whats the best solution to achieve that? here what I create for do that: class Student { public int StudentId { get; set; } public string Name { get; set; } public string Family { get; set; } public List<StudentCourse> Courses { get; set; } } class Course { public int CourseId {