|
Thank you !
I know how to use and work with Entity framework and EF6 with database first.
I want to use it as I've used on Visual studio 2013.
But on Visual studio 2017 , I can't find a way how to start a project with EF6 and Database first.
It seems that VS 2017 is using only Entity framework Core and dropped the support for EF6 ? Or i'm wrong ?
|
|
|
|
|
Sigh ... A little Google goes a long way.
Right-click your project, pick Add --> New Item. Click on Data in the left pane. Double-click ADO.NET Entity Data Model. Follow the wizard.
|
|
|
|
|
desanti wrote: It seems that VS 2017 is using only Entity framework Core and dropped the support for EF6 ? Or i'm wrong ?
You're wrong. I'm using EF6 (not Core) in VS2017, and it's supported perfectly well. You just need to add a reference to the NuGet package called "EntityFramework".
(EF Core is "the future", and will receive the bulk of Microsoft's attention from now on. But there are still a few things that it doesn't support.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: EF Core is "the future", and will receive the bulk of Microsoft's attention from now on
Yeah, there's an upgrade I'm not looking forward to. Hopefully we don't have a ton of work to do on a web app that we spent two years writing, using EF 6.x.
Richard Deeming wrote: ut there are still a few things that it doesn't support
...and there's the reason we haven't dug into it yet.
|
|
|
|
|
And you just know that two months after upgrading, Microsoft will announce that it's being replaced with a newer, shinier version, and the version you've just upgraded to is no longer being maintained.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Man, you speak the truth!
When we started the project it was a about a month before 6.0 came out, so we reworked from 5 to 6.0, then migrations to every 6.x version there is.
Don't get me started on MVC.
|
|
|
|
|
Richard Deeming wrote: (EF Core is "the future", and will receive the bulk of Microsoft's attention from now on. But there are still a few things that it doesn't support.) Right up until they DEPRECATE the bloody thing and come up with some new insanity for us to work with.
AAAAAaaaahhhhhhhhhhhhhhhh pft!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I am given a hard copy consent form that needs to be in a web page including an area for signature. What's the best way to accomplish this?
Thanks
|
|
|
|
|
Hello !
I'm using vb.net 2013 , Entity framework 6 and SQL server 2008R2.
I'm trying to delete from child entities , and this does not work. But if I try to delete directly from context , this works.
In my database I have 2 tables Students and Result
This is my code that does not work :
Dim context as Myentities=New myentities.
Dim s as student.
Dim lresult as new list (of result)
s=context.students.where(Function(t1) t1.value>5).Tolist.first
lresult=(from t in s.results where t.vl2=7 select t).Tolist
for each rs as result in lresult
if rs.vl3=11 then s.results.remove(rs)
Next
Context.savechanges
This code produce an error on the last line( context.savechanges ) :
An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll
Additional information: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.
But if I change the line that delete the item , like below , this works :
Dim context as Myentities=New myentities.
Dim s as student.
Dim lresult as new list (of result)
s=context.students.where(Function(t1) t1.value>5).Tolist.first
lresult=(from t in s.results where t.vl2=7 select t).Tolist
for each rs as result in lresult
if rs.vl3=11 then context.results.remove(rs)
Next
Context.savechanges
Why my first code does not work ?
Thank you !
modified 14-Feb-18 14:33pm.
|
|
|
|
|
Entity Framework Gotchas – Strategies for Orphaned Child Objects[^]
When you call s.results.remove , you're clearing the parent relationship from the entity, but not marking it for deletion.
When you call context.results.remove , you're marking the entity for deletion.
NB: You can clean up your code and improve the performance by not calling ToList when you only want a single object.
s = context.Students.Where(Function(t1) t1.Value > 5).ToList().First()
s = context.Students.Where(Function(t1) t1.Value > 5).First()
s = context.Students.First(Function(t1) t1.Value > 5)
You should also be aware that First will throw an exception if there are no matching records. You might want to consider using FirstOrDefault instead, which will return Nothing if there are no matching records.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
But why when I add a child object I can do directly :
s.results.add(Myobject)
And for the deletion I can't do that as you've said but I should call context.results.remove(Myobject)
So entity framework has different logic for adding and deleting ?
|
|
|
|
|
When you add an entity to the s.results collection, EF sees that it doesn't already exist in the database, and marks it as "Added". It will then insert that record into the database when you save the changes.
When you remove an entity from the s.results collection, EF has no way of knowing whether you wanted to delete the entity from the database, or just remove the connection between the two entities. To avoid inadvertent data-loss, it just tries to remove the connection. To delete it from the database, you have to remove it from the context.results set instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello !
I'm using VB.net 2013 , Entity Framework 6 with sql server 2008R2.
I have a situation where I've made a lot of changes in different entities.
And at the end , I've made a question if the user want to save to database or no .
If yes , I call Savechanges and all the changes are saved.
But if no , I want to undo all the changes made.
Is there any easy way to do this ? I mean , I've found several articles on internet that suggest to undo one by one all the changes.
But is there any easy way , because I don't want to undo specific changes , but all the changes.
Thank you !
|
|
|
|
|
|
Using a simple DAL (not EF) I simply reload the view to get the actual from the database.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you haven't saved the changes, all you have to do is .Dispose() the DbContext instance. The changes die with it.
|
|
|
|
|
I've called
mycontext.dispose.
But after I ca have this code :
Mycontext=New MyEntities
Mycontext.savechanges
and all the changes that I've made before disposing , are saved !!!!!
Why ???
|
|
|
|
|
I have no idea since I can't see your code. You're doing something wrong and actually saving the changes.
Why the hell you're using the last two lines of code after disposing the context is beyond me.
|
|
|
|
|
Just for testing.
So I dispose the context as you've said , and after I try to create a new context , and without making any change , I call Savechanges. And the old changes before disposing are saved.
|
|
|
|
|
The code is doing something other than what you describe. I wrote up a test app to be sure and I don't see the results you're saying you're getting.
The changes I make don't get written to the database and are not persisted in the DbContext change tracker.
Without seeing the code, it's impossible to tell you what's going on.
|
|
|
|
|
Font Stretch and condensed (i.e. Font Scaling) like MSword in vb6 label and textbox
Please Help..
|
|
|
|
|
VB6 was retired many, many years ago; it was replaced with VB.NET.
It is very unlikely you will get a response on how to accomplish your task in VB6; possibly, someone may answer if it is VB.NET related.
Having said that, if you would like some help with an issue, please provide what you've already done. No one will write the code for you, but they may provide help if you show what you've done and explain what it is you're trying to do.
|
|
|
|
|
I want to Fit the Font in Fixed length Textbox and Label how can i do?
|
|
|
|
|
Did you read what I wrote?
Have you provided a code sample?
No one will write the code for you; show what you've done and they may help.
|
|
|
|
|
I have a form which have textbox and dtpicker for inputting data which I store those data in msaccess database. When I export those data to ms excel from another form the date data becomes meaningless or its not exporting as the date enter in the form. Is there anyway to rectify this problem or should I use a text box for inputing date on my form instead of datepicker.
Would be grateful if anyway suggest a way to solve this problem.
Thank you.
Zela
|
|
|
|