entity-framework-4.3

Entity splitting when key column has different names?

十年热恋 提交于 2019-12-18 14:56:14
问题 I'm using Entity Framework 4.3.1 Code-First and I need to split an entity between two tables. The tables have a primary key shared, and it is 1-to-1, but the columns are not named the same on each table. I don't control the data layout, nor can I request any changes. So for example, the SQL tables could be And this would be my entity... public class MyEntity { public int Id {get; set;} public string Name {get;set} public string FromAnotherTable {get;set;} } And here is the mapping I have.

How can I disable the use of the __MigrationHistory table in Entity Framework 4.3 Code First?

扶醉桌前 提交于 2019-12-18 04:45:45
问题 I'm using Entity Framework 4.3 Code First with a custom database initializer like this: public class MyContext : DbContext { public MyContext() { Database.SetInitializer(new MyContextInitializer()); } } public class MyContextInitializer : CreateDatabaseIfNotExists<MyContext> { protected override void Seed(MyContext context) { // Add defaults to certain tables in the database base.Seed(context); } } Whenever my model changes, I edit my POCO's and mappings manually and I update my database

How to seed data with AddOrUpdate with a complex key in EF 4.3

点点圈 提交于 2019-12-17 21:42:21
问题 I am trying to seed a development database with some test data. I have used context.People.AddOrUpdate(p => p.Id, people)); with much success. I have another table that I need to seed, in which I would not know the primary key. For example, I would want to AddOrUpdate based on the First and Last names matching. I am unsure how to write the Expression correctly. context.People.AddOrUpdate(p => p.FirstName && p.LastName, people); is obviously incorrect, but I hope it conveys the solution I am

Mapping a foreign key with a custom column name

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 15:47:14
问题 I'm using Entity Framework 4.3 code-first with Oracle. I'm getting the following error: System.InvalidOperationException : The ForeignKeyAttribute on property 'WidgetSequence' on type 'WidgetDistributor.WidgetEntity' is not valid. The foreign key name 'WIDGETSEQUENCE_ID' was not found on the dependent type 'WidgetDistributor.WidgetEntity'. The Name value should be a comma separated list of foreign key property names. My entities are like this: [Table("WIDGETENTITIES")] public class

Linq when using GroupBy, Include is not working

故事扮演 提交于 2019-12-17 15:39:45
问题 include matchparticipants is not working. It always says Null when I debug. But when I put the GroupBy in comment it works fine. I am using Entity framework 4.3.1 with code-first. Entities: public class Match { [ScaffoldColumn(false)] public int MatchId { get; set; } [Required(ErrorMessage = "Matchtype is a required field")] public int Scheme { get; set; } [Required] [DefaultValue(false)] public bool Finished { get; set; } public int Round { get; set; } // Relations [Required] public Category

Linq when using GroupBy, Include is not working

陌路散爱 提交于 2019-12-17 15:39:00
问题 include matchparticipants is not working. It always says Null when I debug. But when I put the GroupBy in comment it works fine. I am using Entity framework 4.3.1 with code-first. Entities: public class Match { [ScaffoldColumn(false)] public int MatchId { get; set; } [Required(ErrorMessage = "Matchtype is a required field")] public int Scheme { get; set; } [Required] [DefaultValue(false)] public bool Finished { get; set; } public int Round { get; set; } // Relations [Required] public Category

Entity Framework 4.3: 'update-database' when configuration files are separated

馋奶兔 提交于 2019-12-13 13:45:17
问题 Moved to ef 4.3 with AutomaticMigrationsEnabled = true; In web.config have the following settings: <appSettings configSource="appSettings.config" /> <connectionStrings configSource="connectionStrings.config" /> In Package Manager Console execute update-database -verbose and got the following error: System.Configuration.ConfigurationErrorsException: Unable to open configSource file 'connectionStrings.config' The error is understandable: it tries to open connectionStrings.config file from the

Where the CREATE DATABASE statement is generated in Entity Framework Code First with Migrations?

只愿长相守 提交于 2019-12-13 07:20:21
问题 I need to configure the database created by Entity Framework Code First MigrateDatabaseToLatestVersion class. Is it possible to influence the database files parameters like size or maxsize? What interests me in particular, is there a way to add database files? I assume I need to find the moment where the Entity Framework generates the CREATE DATABASE statement and influence it a bit. As far as I understand, the SqlServerMigrationSqlGenerator class is too late because the database already

EF 4.3 Code First Migrations - Uncompress __MigrationHistory Model

谁说胖子不能爱 提交于 2019-12-13 06:10:47
问题 How can I uncompress/read the compressed models stored in the EF 4.3 Code First Migrations __MigrationHistory table? I found a hint in this comment, that I can uncompress it using zip/gzip, but I don't know how exactly I should do this. The problem is that I have changed something in my ef model classes, but when I call "add-migration" an empty migration ist generated. I think that is because the changes of my model classes are already assigned to an existing migration :( 回答1: (this may be a

hotfix: Principal entity in an SQL application generates unnecessary updates - do it still effect EF 4.3.1?

自闭症网瘾萝莉.ら 提交于 2019-12-13 02:31:12
问题 There is an issue reported on MSDN regarding concurrency exceptions which we think we are seeing. http://support.microsoft.com/kb/2390624 It's quite an old issue, does it still effect EF 4.3.1? 回答1: EF 4.1, 4.2, 4.3 and 4.3.1 are built on top of System.Data.Entity.dll that is part of .NET Framework. Since the issue is in System.Data.Entity.dll all the 4.x releases are affected by the problem. This should be fixed in .NET Framework 4.5 Beta so you can either request the hotfix or move to .NET