tag:blogger.com,1999:blog-5238131531249720750.post4880639492129960646..comments2024-03-19T13:28:26.291+01:00Comments on Everything SQL Server Compact: Saving images and long strings to SQL Server Compact with Entity Framework 4.1 Code FirstErikEJhttp://www.blogger.com/profile/12641272161018114573noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-5238131531249720750.post-37456909629817660662017-01-05T07:36:11.901+01:002017-01-05T07:36:11.901+01:00Ricky: Let us continue the support discussion here...Ricky: Let us continue the support discussion here: https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/issues/179 - and please provide the database schema and the code generating this error.ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-62579432686161113212017-01-05T04:37:55.474+01:002017-01-05T04:37:55.474+01:00I've a SQL Server Compact database. I did a re...I've a SQL Server Compact database. I did a reverse POCO after following article: <br /><br />https://github.com/ErikEJ/SqlCeToolbox/wiki/EntityFramework-Reverse-POCO-Code-First-Generator.<br /><br />But I'm getting exception: System.NotSupportedException<br />Message: "Binary column with MaxLength greater than 8000 is not supported."<br /><br />It's recommended not to change file generated by reverse POCO. What should I do to overcome this limitation?<br />Anonymoushttps://www.blogger.com/profile/09608006380608260182noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-85554639245342776022013-11-02T19:41:55.578+01:002013-11-02T19:41:55.578+01:00My mistake. Your doubt is correct. I also could no...My mistake. Your doubt is correct. I also could not reproduce the error with EF6.<br />Oh god...my wrong and blind mind...D'oh! <br />I was setting the wrong property... :)Everything works fine now. Thanks for your answer. Nice blog.<br />Regards.Mr. Bithttps://www.blogger.com/profile/06048074370799167695noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-77128263522179993632013-11-02T15:02:14.141+01:002013-11-02T15:02:14.141+01:00Mr. Bit - deleted your comment by mistake, but dou...Mr. Bit - deleted your comment by mistake, but doubt I can repro with EF6, as stated above, pls email repro project to meErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-46504866186292444232013-10-30T09:33:18.859+01:002013-10-30T09:33:18.859+01:00Simon: Sorry,cannot repro with EF6 Simon: Sorry,cannot repro with EF6 ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-33450413988366386952013-10-29T16:23:02.518+01:002013-10-29T16:23:02.518+01:00I will test with EF6 and let you know... Otherwise...I will test with EF6 and let you know... Otherwise email me a repro projectErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-34668564861780228392013-10-29T16:20:15.625+01:002013-10-29T16:20:15.625+01:00I get it when calling DbContext.SaveChanges(). I a...I get it when calling DbContext.SaveChanges(). I am using EF 5.0Simonhttps://www.blogger.com/profile/16012158517468087222noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-21648348972449706892013-10-29T16:10:54.789+01:002013-10-29T16:10:54.789+01:00Simon: That sound odd. When do you get this messag...Simon: That sound odd. When do you get this message? Using which EF version?ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-21836814143974926012013-10-29T15:53:15.573+01:002013-10-29T15:53:15.573+01:00If I use [MaxLength] without any parameters, I get...If I use [MaxLength] without any parameters, I get "Default values not supported". If I set a value like [MaxLength(N)] N cannot be bigger than 8000. Is there a way to store blobs that are bigger than 8000?Simonhttps://www.blogger.com/profile/16012158517468087222noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-29313128148484079982013-03-18T18:15:50.026+01:002013-03-18T18:15:50.026+01:00I see now, that simply specifying MaxLength preven...I see now, that simply specifying MaxLength prevents any validation errors! Will update the blog post and make a note on SO also - thanks.ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-16816859735136502732013-03-18T18:02:36.507+01:002013-03-18T18:02:36.507+01:00I will test that, but I cannot see what "code...I will test that, but I cannot see what "code" you posted on SO !?ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-61685658709671320132013-03-18T17:57:54.835+01:002013-03-18T17:57:54.835+01:00Your code tells EF to not validate the Student ent...Your code tells EF to not validate the Student entity at all. The code I was suggesting would only remove the validation error against the specific property that was causing a problem (for example the Photo property). Turns out that after I posted this suggestion here (and on stackoverflow) I tested using MaxlengthAttribute without a parameter and found that it works too to prevent the EF validation error. So using Maxlength is an even better answer.arobincaronhttps://www.blogger.com/profile/18358750158508337518noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-68620311529348742272013-03-18T17:48:14.885+01:002013-03-18T17:48:14.885+01:00Arobin: Is that not what I am doing already?Arobin: Is that not what I am doing already?ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-73155303956532466312013-03-18T17:37:52.442+01:002013-03-18T17:37:52.442+01:00Thank you for your post -- it got me back on track...Thank you for your post -- it got me back on track with saving images. Have you considered instead of disabling validation to instead remove the EF validation error that prevents the save from going through. You do that by overriding the DbContext.ValidateEntity method. I posted code here: http://stackoverflow.com/a/15481902/1030660arobincaronhttps://www.blogger.com/profile/18358750158508337518noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-14936696799820196242012-08-30T07:32:15.929+02:002012-08-30T07:32:15.929+02:00Steve: Thanks for the heads up, nice to know that ...Steve: Thanks for the heads up, nice to know that this is still useful info!ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-41734903708332148522012-08-30T05:22:42.652+02:002012-08-30T05:22:42.652+02:00This still seems to be a problem in EF 5.0This still seems to be a problem in EF 5.0Steve Chadbournehttps://www.blogger.com/profile/02596148869184331473noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-10360333029250067592012-02-08T09:20:34.242+01:002012-02-08T09:20:34.242+01:00SB: Just select the image byte array from the data...SB: Just select the image byte array from the database, and convert to an imageErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-22404354935879054842011-11-09T09:42:59.665+01:002011-11-09T09:42:59.665+01:00I have replied to your emailI have replied to your emailErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-17667530970624294242011-11-09T08:43:33.642+01:002011-11-09T08:43:33.642+01:00Erik I don't want to focus on the logic I use ...Erik I don't want to focus on the logic I use to get the new IDs, just suppose I have one and it wors fine. For instance you could delete all the records in the students table and then try to add a new record with ID = 1. Doing so I get the DbUpdateException I told you.<br />I'm going to email you my sample code...obondohttps://www.blogger.com/profile/15140506955526136606noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-8187278791353653962011-11-08T09:47:30.204+01:002011-11-08T09:47:30.204+01:00Hi, how can you introduce logic without code chang...Hi, how can you introduce logic without code changes? Can you share your project? (Email via contact info on the blog)ErikEJhttps://www.blogger.com/profile/12641272161018114573noreply@blogger.comtag:blogger.com,1999:blog-5238131531249720750.post-9262441800857444502011-11-08T09:28:38.343+01:002011-11-08T09:28:38.343+01:00Hi Erik, this post is very interesting to me, but
...Hi Erik, this post is very interesting to me, but<br />now I have a question for you: suppose I need to assign student's IDs manually so I change table schema to reflect this; the StudentId column is still primary key but its identity property is set to false.<br />The code in Program.cs remains the same, I just introduce some logic to generate a new ID each time I need to add a student.<br />When I run the app I get a DbUpdateException on the db.SaveChanges() call telling me that I'm trying to assign a NULL value to the StudentId column. That's not true as I verified I assigned a new value to that column.<br />Why is this happening?<br /><br />Thanks very much in advance<br />andreaobondohttps://www.blogger.com/profile/15140506955526136606noreply@blogger.com