entity-framework-6

EF: Create/Remove relation from Many-to-Many relations when `AutoDetectChangesEnabled` and `ProxyCreationEnabled` are disabled on DbContext

左心房为你撑大大i 提交于 2019-12-20 04:25:37
问题 Knowning Foo.Id and Bar.Id how can I create their relation without loading the entities from the DB. class Foo { public int Id { get; set; } public Lst<Bar> Bars { get; set; } } class Bar { public int Id { get; set; } public Lst<Foo> Foos { get; set; } } Also this configuration are disabled in DbContext constructor: Configuration.AutoDetectChangesEnabled = false; Configuration.ProxyCreationEnabled = false; Configuration.LazyLoadingEnabled = false; And how it is possible to remove the

PostgreSQL data provider missing from wizard in Visual Studio 2015

陌路散爱 提交于 2019-12-20 04:23:22
问题 I've spent a day trying to migrate an Entity Framework 6 SQL Server CE to PostgreSQL. I've copied the database over fine, but I can't seem to get the data provider to work. Firstly I tried the older 2.2.7 version of the EF provider, which doesn't require .NET 4.5 (because our project can't use it), but that didn't work. I've been using NpgsqlConnection instead of SqlConnectionStringBuilder and changed the app.config to have a connection string with Host (I tried Server but it didn't like it)

Entity Framework 6. Disable ModelCaching

∥☆過路亽.° 提交于 2019-12-20 02:56:20
问题 OK, Google, I am not able to googling it. Documentation says The model for that context is then cached and is for all further instances of the context in the app domain. This caching can be disabled by setting the ModelCaching property on the given ModelBuidler and SO confirms it. But i can't find way to do it. I have to disable caching because i want to get data from several log table with same structure via just one model, so my code looks like logTableNames.ForEach(n => { using (var

Manually add a migration?

孤街醉人 提交于 2019-12-20 02:05:53
问题 I've been using Entity framework code first in a project and all the tables have been created /modified a while ago. Now I need to add an unique constraint to a table. I want to create a migration which will have the following row in the Up() method. And there is no change on the model classes . CreateIndex("TableName", new[] { "Column1" }, true, "IX_UniqueKey"); And maybe the following row in the Down() DropIndex("TableName", new [] { "Column1" }); Can I just manually create a file under the

EF6 POCO INotifyPropertyChanged without viewmodels

为君一笑 提交于 2019-12-20 01:58:27
问题 I have been binding in WPF application directly to the model classes (and skipping creating individual viewmodel classes). Now, after switching to EF6 and DBContext, I face an issue with the generated EF POCO classes since it looks its either kind of tricky or not even recommended trying to make INotifyPropertyChanged interface implemented directly to those classes. Currently: I don't want to go back to ObjectContext. I don't want to change T4 too much either. The suggestions on the web for

EF6 does not lazy load navigation property

半城伤御伤魂 提交于 2019-12-20 01:37:28
问题 I'm having an issue with EF6 lazy loading. I've searched StackOverflow, but the other questions I've found doesn't fit my case. I'm using the virtual keyword and my classes are public . LazyLoadingEnabled and ProxyCreationEnabled are both set to true . When I load a course object from the db, presentationId is set to the correct id and presentation is null which is correct, because it hasn't been loaded yet. When I pass the presentation property to the PresentationsController.ToDto() method

EF6 - TPH foreign key mapping in derived classes using base class property

自作多情 提交于 2019-12-19 21:46:29
问题 I am using Entity Framework 6.0.2 with an existing database in which tags are stored in a single table that looks like this: Id : int, primary key TagType : string, determine the type of tag, either "usertag" or "movietag" ItemId : int, contains the Id of the item to which is referred (either a User Id or a Movie Id) The following classes describe this situation: public class User { public int Id { get; set; } } public class Movie { public int Id { get; set; } } public abstract class Tag {

EF6 - TPH foreign key mapping in derived classes using base class property

走远了吗. 提交于 2019-12-19 21:46:23
问题 I am using Entity Framework 6.0.2 with an existing database in which tags are stored in a single table that looks like this: Id : int, primary key TagType : string, determine the type of tag, either "usertag" or "movietag" ItemId : int, contains the Id of the item to which is referred (either a User Id or a Movie Id) The following classes describe this situation: public class User { public int Id { get; set; } } public class Movie { public int Id { get; set; } } public abstract class Tag {

EF6 - TPH foreign key mapping in derived classes using base class property

别等时光非礼了梦想. 提交于 2019-12-19 21:46:22
问题 I am using Entity Framework 6.0.2 with an existing database in which tags are stored in a single table that looks like this: Id : int, primary key TagType : string, determine the type of tag, either "usertag" or "movietag" ItemId : int, contains the Id of the item to which is referred (either a User Id or a Movie Id) The following classes describe this situation: public class User { public int Id { get; set; } } public class Movie { public int Id { get; set; } } public abstract class Tag {

Why can't I see a localdb database created by a UWP (Desktop Bridge App) in the SQL Server Object Explorer?

邮差的信 提交于 2019-12-19 19:52:41
问题 Does UWP support LocalDB? My investigations indicate there are some issues using localdb that I don't experience with SQL Server 2017 Development edition. I managed to convert a winforms EF-Code First, xaf application to run as a UWP app with the help of this blog I have Enterprise Authentication set. When I run the desktop bridge app it creates the database and log file inside c:\users\kirst which is my user folder. However I cannot see the new database in the SQL Server Object Explorer