entity-framework-4

Ado.net EDMX model table fields custom validation

冷暖自知 提交于 2020-01-06 10:32:32
问题 I have generated the data table model using the option "Generate model from database" in the entity framework and now the model contains the IDE generated code of the models. The models are working fine and now I have a problem, because I want to add custom validations to the table fields and the error messages & the field names should be taken from the resource file. The validation should be done in the ajax call. Can anyone help me to add these validations to the automatically generated

What's the best way to force EF to return all rows in a view?

筅森魡賤 提交于 2020-01-06 09:29:11
问题 I have a view where one of the joined columns is nullable but is often the only distinguishing item between two rows. I see that EF built a primary key out of all the non-nullable items in the view. I've noticed that when I pull from the view, this nullable column does not always get returned correctly, and I read that it has to do with the way it maps to the key, and will return the same row if it sees the key already exists. Ideally the best solution would be to make my column not-nullable,

No key defined error on entity after branching in TFS

余生长醉 提交于 2020-01-06 07:38:24
问题 We are consistently getting the following RIA error message, after branching a team project in TFS: The Entity 'abc' in DomainService 'MyDomainService' does not have a key defined. Entity types exposed by DomainService operations must have at least one public property marked with the KeyAttribute. Everything works in the source branch, and when comparing the two branches there is absolutely no difference. I have also tried to install TFS 2012 on a virtual machine, import the project there,

EF4 Linq Oracle11g making queries none case-sensitive

吃可爱长大的小学妹 提交于 2020-01-06 07:19:33
问题 We are moving to EF4 & Linq as our db interface to a Oracle 11g db. The database is setup as case sensitive, but we need to search as case insensitive. In oracle using "UPPER" in the query is potentially very expensive. I have looked at the following options with the indicated results: ChangeEntities.TABLE.Where(x => x.FIELD.Equals(VARIABLE)) generates SQL Where clause: WHERE TABLE.FIELD = VARIABLE --------------------- ChangeEntities.TABLE.Where(x => x.FIELD.Equals(VARIABLE.ToUpper()))

How should I name database wrapper object?

感情迁移 提交于 2020-01-05 19:08:02
问题 For my CMS application I'm writing a DLL that I will include into my projects. That DLL will include functionality like retrieving all news for a specific project. For instance, my database contains a table called News. By using the Entity Framework 4 I have a automatic generated class called News . I do not want my DLL methods return this object rather than a wrapper class, that only contains properties. How should I name this wrapper class? For now I've always appended the word "Container",

How should I name database wrapper object?

六眼飞鱼酱① 提交于 2020-01-05 19:07:51
问题 For my CMS application I'm writing a DLL that I will include into my projects. That DLL will include functionality like retrieving all news for a specific project. For instance, my database contains a table called News. By using the Entity Framework 4 I have a automatic generated class called News . I do not want my DLL methods return this object rather than a wrapper class, that only contains properties. How should I name this wrapper class? For now I've always appended the word "Container",

Map a column to be IDENTITY in db

戏子无情 提交于 2020-01-05 16:32:42
问题 Although I have marked my ID column with .Identity() , the generated database schema doesn't have IDENTITY set to true, which gives me problems when I'm adding records. If I manually edit the database schema (in SQL Management Studio) to have the Id column marked IDENTITY , everything works as I want it - I just can't make EF do that by itself. This is my complete mapping: public class EntryConfiguration : EntityConfiguration<Entry> { public EntryConfiguration() { Property(e => e.Id)

ASP.NET and Entity Framework Customizing The GridView Field Header

为君一笑 提交于 2020-01-05 12:13:11
问题 Can you please let me know how I can Customize the header for fields in Grid View using Entity Framwork and ASP.NET? For Example I have dbcontext instance which is showing on the GridView like this image: Now I would like to change the Header Style, Format and Presentation to some thing like this: I am gussing some part of job can be done through CSS styling like changing color but for Changing the CONTRACTORID TO Contractor ID I do not know how to do it? Can you please let me know how to

How to save a file path at database?

断了今生、忘了曾经 提交于 2020-01-05 07:31:11
问题 i'm doing a music upload to my application, using the uploadify plugin, the upload are working, but, when i'll save the path reference (where the music are saved on my project), i'm getting null value, anyone knows how can I do this? Upload Method at MusicController public ActionResult Upload() { var file = Request.Files["Filedata"]; string savePath = Server.MapPath(@"~\mp3\" + file.FileName); file.SaveAs(savePath); return Content(Url.Content(@"~\mp3\" + file.FileName)); } Create Method at

AutoGenerate Identity Negative PK in EF4

被刻印的时光 ゝ 提交于 2020-01-05 07:30:12
问题 I am using EF 4.4.0.0 and following custom methods for generating identity negative PK: private int? GetMinId() { return Context.ENTITY.Min(c => (int?)c.Id); } public int GenerateNegativeId() { var minId = GetMinId() ?? default(int); if (0 < minId) return minId * -1; if (0 > minId) return --minId; return -1; } Could you explain how to AutoGenerate Identity Negative PK ids. (Is it possible?) Thank you 回答1: This is not possible, because identity generation happens on the database side. Why do