entity-framework-core

Visual Studio for Mac connection to remote MS SQL Server failed

不羁的心 提交于 2020-01-04 06:55:11
问题 I'm using Visual Studio for Mac 2017 on macOS Sierra with Microsoft EntityframeworkCore and I'm trying to connect to a remote MS SQL Server. If I start the project in Visual Studio on my Windows machine, everything works fine. But the same project on my Mac tells me "A call to SSPI failed" when I try to get data from the SQL Server. I can connect to the SQL Server using the "Oracle SQL Developer" tool on my Mac. So the issue is somewhere in Visual Studio. The connection string: Server

Can't apply $select when using ODataQueryOptions

两盒软妹~` 提交于 2020-01-04 05:57:22
问题 I am trying to implement querying to Sql Server via EF Core and OData(7.1.0). Action method looks like follows: [HttpGet] public IEnumerable<UserInfoDto> Get(ODataQueryOptions ops) { return this.service.GetUserInfos(ops); } Service code: public List<UserInfoDto> GetUserInfos(ODataQueryOptions ops) { using (var context = new EFContext()) { var query = context.Users.Join(context.Customers, x => x.CustomerId, y => y.Id, (x, y) => new UserInfoDto { Id = x.Id, Name = x.Name, Age = x.Age,

Entity Framework core one to one relationship generate one to many in SQL Server

时间秒杀一切 提交于 2020-01-04 02:17:32
问题 For one-to-one relationship in Entity Framework core (rc1 or rc2) based on this tutorial http://ef.readthedocs.io/en/latest/modeling/relationships.html#one-to-one, I use this code: public class MyContext : DbContext { public DbSet<Blog> Blogs { get; set; } public DbSet<BlogImage> BlogImages { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Blog>() .HasOne(p => p.BlogImage) .WithOne(i => i.Blog) .HasForeignKey<BlogImage>(b => b

Entity Framework 7 cascading inserts

徘徊边缘 提交于 2020-01-03 17:47:10
问题 We have just done a merge to EF7 from EF6, since we use ASP.Net 5 in our application. The project is just started, so we won't run into issues with releasing code dependent on beta libraries. We have run into an issue with cascading inserts. By cascading inserts I mean that a collection of child entities is inserted / updated with the parent. It seems to be dependent on the order of operations in a surprising way. Given the following definitions: public class ParentEntity { public int Id {

How do I write EF.Functions extension method?

Deadly 提交于 2020-01-03 15:33:29
问题 I see that EF Core 2 has EF.Functions property EF Core 2.0 Announcement which can be used by EF Core or providers to define methods that map to database functions or operators so that those can be invoked in LINQ queries . It included LIKE method that gets sent to the database. But I need a different method, SOUNDEX() that is not included. How do I write such a method that passes the function to the database the way DbFunction attribute did in EF6? Or I need to wait for MS to implement it?

Entity Framework Core 1.0 code-first migrations using code?

折月煮酒 提交于 2020-01-03 15:20:14
问题 In previous versions of Entity Framework code-first migrations could be controlled programmatically with the DbMigrator class (e.g. check for and apply available migrations). Does that class still exist somewhere or is there a functional replacement? I found a post on an early RC version that indicated a substitute but that too seems to be missing from Core 1.0. I can control my migrations through CLI without issue but I think an in-code solution for custom tooling scenarios is going to be

EntityFramework Core 1.1.0 missing Include()? [duplicate]

我的未来我决定 提交于 2020-01-03 09:47:04
问题 This question already has an answer here : Entity Framework Core does not contain a definition for 'Include' (1 answer) Closed last year . I am using EntityFramework Core 1.1.0. I can query a table and load entities, but the instructions from Microsoft indicates if I want to load relational data, I should use the .Include() function: https://docs.microsoft.com/en-us/ef/core/querying/related-data You can use the Include method to specify related data to be included in query results. In the

'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'

大城市里の小女人 提交于 2020-01-03 08:53:12
问题 It's my first time using asp 5\core1 and i'm having problem setting a entity framework dbcontext I have one class library with my object public class Utilizador { public Utilizador() { } public int id { get; set; } } Then i have a Web Api project with a reference to my class and a context public class Context : DbContext { public Context(DbContextOptions<Context> options) : base(options) { } public DbSet<Utilizador> Utilizadores { get; set; } } My package.json its like this regarding entity

'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'

主宰稳场 提交于 2020-01-03 08:53:08
问题 It's my first time using asp 5\core1 and i'm having problem setting a entity framework dbcontext I have one class library with my object public class Utilizador { public Utilizador() { } public int id { get; set; } } Then i have a Web Api project with a reference to my class and a context public class Context : DbContext { public Context(DbContextOptions<Context> options) : base(options) { } public DbSet<Utilizador> Utilizadores { get; set; } } My package.json its like this regarding entity

Migrating data when adding one-to-one relationship in EF Core?

社会主义新天地 提交于 2020-01-03 08:49:13
问题 After adding a new one-to-one relation to one of my table I cannot figure out how to add default data for existing rows in my database. My database basically looked like this before upgrade: -- Team -- Name: TEXT -- History -- Id: INT ... where History is has foreign keys pointed to it from other unrelated tables. In my upgrade I basically want a Team to have a single History so my new db looks like: -- Team -- Name: TEXT HistoryId: INT -- History -- Id: INT My problem now, however is that I