entity-framework-4

edmx validation throws an error about collide primary key

为君一笑 提交于 2019-12-12 03:39:48
问题 I have 3 entities: BaseUser , AuthenticationUser and User . AuthenticationUser inherit from BaseUser and User inherit from AuthenticationUser . User entity has scalar property of type Binary (photo) so I would like to split the User entity into User and UserPhoto . I did exactly what this nice article sais: http://www.deveducate.com/blog/post/2010/12/14/Entity-Framework-Modeling-Table-Splitting.aspx Here is an image of my edmx: When I validate the edmx I keep getting this error: Error 3033:

How to create dynamic database in entity framework with specified path?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 03:09:58
问题 currently i create dynamic database using CreateDatabase() method in Entity Framework. it executes sucessfully and it creates database at following path: "c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA" but i want to create database in my application's directory. how to do this? please help me. 回答1: Normally all databases are created on default path configured in SQL Server. Only if you are using SQL Server Express and if you define connection string which specifies

Navigation properties not set when using ADO.NET Mocking Context Generator

こ雲淡風輕ζ 提交于 2019-12-12 03:03:48
问题 I am using ADO.NET Mocking Context Generator plugin for my Entity Framework model. I have not started on using mocks yet, just trying to fix generated entity and context classes to make application run as before without exceptions. I've already fixed T4 template to support SaveChanges method. Now I've got another problem: when I try to access any navigation property it is set to null. All the primitive fields inherited from DB table are set and correct. So what I am doing is the following

Changing EF Model and creating new entities in runtime

若如初见. 提交于 2019-12-12 02:57:54
问题 I'm using EF4 in model (DB First), POCO in entities, ASP.Net in UI. I have a Biz layer of course. I need to design dynamic form generator. I decide to create a table from forms design by users, and then update my EF model in runtime, generate POCO objects and biz logic in runtime, and then compile them in runtime. I have problem about updating model in runtime. any help? Thanks in advance -Hamid 回答1: EF is not tool for your problem! EF is build around simple concept - mapping and classes are

Repository EF DBContext

牧云@^-^@ 提交于 2019-12-12 02:33:36
问题 my question is a two part issue. I am using the repository and unit of work pattern with entity framework. I have the following StockTransferRepository and StockTransfer is my aggregateRoot. Public Class StockTransferRepository Inherits WMSBaseRepository(Of StockTransfer, Int64, Dictionary(Of String, String)) Implements IStockTransferRepository Public Sub New(uow As IUnitOfWork) MyBase.New(uow) End Sub Public Overrides Function GetObjectSet() As IQueryable(Of StockTransfer) Return

LINQ understading Non-Equijoins

筅森魡賤 提交于 2019-12-12 02:33:05
问题 I use asp.net 4, ef 4 and c#, LINQ and Non-Equijoins. Here below I wrote two examples of Non-Equijoins. Both are working fine in my model. Because I'm pretty new to Linq, I would like ask you: Which syntax typology would you advice me to adopt in my code? Which code performance faster? Thanks for your help: Here some useful links: http://msdn.microsoft.com/en-us/library/bb882533.aspx http://msdn.microsoft.com/en-us/library/bb311040.aspx http://msdn.microsoft.com/en-us/library/bb310804.aspx //

Insert an Identity Value using Entity Framework

倾然丶 夕夏残阳落幕 提交于 2019-12-12 02:28:00
问题 Note: This seems to have been asked indirectly several times, but never really answered. I have a row that I delete using Entity Framework. When I delete it I archive it in a different table. In some cases that row needs to be restored to the table it came from. But here is the kicker, I would really really like it to have the exact same ID it had when it was deleted (I actually need to restore rows from several tables that are FKed off this ID). Is there any way to have EF put a row in with

Interpreting byte[] in stored procedure

不羁的心 提交于 2019-12-12 02:25:51
问题 A proc we have searches an encrypted field by encrypting the search field and comparing these encrypted values. What I need though to be able to do is to pass into the proc (through Entity Framework 4) the encrypted value (as the code encrypts it), but also allow null if the value is not provided. So I need to pass in a byte[] but it also needs to accept nulls... is this even possible, or what is a workaround if its not? Again, I'm calling a stored procedure through entity framework. Thanks.

Why does EntityFramework do SELECT a,b,c FROM (SELECT a,b,c FROM MyView)?

爱⌒轻易说出口 提交于 2019-12-12 02:23:39
问题 I followed the tutorial here to auto-generate my POCO classes from an existing MySQL database. The generated POCO classes worked as expected for all of my MySQL table objects. The database also has a fairly complex, legacy MySQL view that references 8 tables using both INNER and LEFT OUTER joins. The view itself is fine and there's no issue when tested in MySQL workbench. However, when I tried to select a few records using the auto-generated POCO class for the view, the operation timed out

Updating a list of foreign keys in EF4, using MVC 2 Repository Viewmodel Pattern

喜夏-厌秋 提交于 2019-12-12 02:08:59
问题 Okay, I'm really struggling with how to update a list of foreign keys in MVC2/EF4. I have a one to many relationship between a Template object which can have many or no TemplateScenario objects. Essentially, I have an edit method in a controller that is trying to do this: // POST: /Modes/Edit/1 [HttpPost] public ActionResult Edit(int id, FormCollection formValues) { Template template = _templateRepository.GetTemplate(id); TemplateCreateViewModel viewModel = new TemplateCreateViewModel();