Asked by:
Can't reference Entity's NameSpace

Question
-
User1935984934 posted
I created an entity and would like to reference it in my code but it doesn't come up. I clean/build/rebuild project and solution.
What am I missing ?
It looks like I am missing this and my model is not empty.
Tuesday, October 9, 2018 11:01 PM
All replies
-
User1120430333 posted
What am I missing ?
You most likely are missing an Import statement that gives refernce to the code in the namespace.
imports ProcessSGCModel
Wednesday, October 10, 2018 3:18 AM -
User1935984934 posted
DA924
You most likely are missing an Import statement that gives refernce to the code in the namespace.Tried it no it didn't work.
Going thru http://www.entityframeworktutorial.net seems to be a good way to start
Wednesday, October 10, 2018 11:12 AM -
User753101303 posted
Hi,
From what I see this namespace is used inside your EDMX XML file. Use the "Object Explorer" to search and see where are your programming classes.
If you want to move your classes inside a namespace it should be defined in the "custom tool namespace" defined at the tt file level...
Edit: EDMX is a bit outdated (no support in ASP.NET Core). You could have a look at "code first" or "code first from database" first.
Wednesday, October 10, 2018 11:40 AM -
User1120430333 posted
DA924
You most likely are missing an Import statement that gives refernce to the code in the namespace.Tried it no it didn't work.
Going thru http://www.entityframeworktutorial.net seems to be a good way to start
I use EF 6 DB First using VB.NET. What I like to do is make a Visual Stuido Folder in the project, install EF into the folder and get the EF code separated from other code in the project, which is namespace seperation. I name the folder Model. At best, you may need to Import Model. I do it for C# project too that is using EF 6 is make the Model folder and install EF into it. I do it for EF Core too is make the Model folder and install EF into it.
I didn't have to Import Model, becuase in this regards VB is somewhat better where you don't have to use Imports at times.
Imports Entities Public Class DaoCache implements IDaoCache Private ReadOnly context As ProjectManagementEntities public sub New (dbcontext As ProjectManagementEntities) context = dbcontext End sub public Function GetCache() As DtoCache Implements IDaoCache.GetCache Dim dtocache = New DtoCache() dim projectypes = (from a in context.ProjectTypes select a).ToList() CreateProjectTypes(dtocache, projectypes) dim statuses = (from a in context.Statuses select a).ToList() CreateStatuses(dtocache, statuses) dim resources = (from a in context.Resources select a).ToList() CreateResources(dtocache, resources) dim durations = (from a in context.Durations select a).ToList() CreateDurations(dtocache, durations) Return dtocache End Function Private Shared Sub CreateProjectTypes(byval dtocache As DtoCache, byval projectypes As List(Of ProjectType)) For Each pt As ProjectType In projectypes Dim dto = new DtoProjectType() With{.ProjectTypeId = pt.ProjectTypeId, .Text = pt.Text, .Value = pt.Value} dtocache.ProjectTypes.Add(dto) Next End Sub Private Shared Sub CreateStatuses(byval dtocache As DtoCache, byval statuses As List(Of Status)) For Each st As Status In statuses Dim dto = new DtoStatus() With{.StatusId = st.StatusId, .Text = st.Text, .Value = st.Value} dtocache.Statuses.Add(dto) Next End Sub Private Shared Sub CreateResources(byval dtocache As DtoCache, byval resources As List(Of Resource)) For Each rs As Resource In resources Dim dto = new DtoResource() With{.ResourceId = rs.ResourceId, .Text = rs.Text, .Value = rs.Value} dtocache.Resources.Add(dto) Next End Sub Private Shared Sub CreateDurations(byval dtocache As DtoCache, byval durations As List(Of Duration)) For Each du As Duration In durations Dim dto = new DtoDuration() With{.DurationId = du.DurationId, .Text = du.Text, .Value = du.Value} dtocache.Durations.Add(dto) Next End Sub End Class
Wednesday, October 10, 2018 12:28 PM -
User1935984934 posted
I didn't have to Import Model, becuase in this regards VB is somewhat better where you don't have to use Imports at times.
You're right, I didn't have clarity on some concepts but eventually I got it all up and running fine. Good idea to have EF into a separate folder.
Wednesday, October 10, 2018 2:10 PM -
User1935984934 posted
Edit: EDMX is a bit outdated (no support in ASP.NET Core). You could have a look at "code first" or "code first from database" first.
The reason I used EF was to solve a performance issue I had on a grid (and the improvement is huge) . I read about "code first" but with the amount of time I had to solve my problem it seemed to be a too big change to use it yet.
Wednesday, October 10, 2018 2:13 PM -
User753101303 posted
I used EF to solve a performance issueIt's a bit weird. Behind the scene it still create SQL statements and uses ADO.NET so EF should run at a similar speed or a bit slower. There is nothing in EF that should make it "faster by design" than with ADO.NET hand written code.
Wednesday, October 10, 2018 2:35 PM -
User1935984934 posted
PatriceSc
It's a bit weird. Behind the scene it still create SQL statements and uses ADO.NET so EF should run at a similar speed or a bit slower. There is nothing in EF that should make it "faster by design" than with ADO.NET hand written code.
Perhaps it is due to the grid I am using (which is DevExpress AsxpxGridview, by the way) I had a chat with their support and they suggested using Entity Data Source as they are showing in their demo here. Displaying the grid itself was fine but it was the search inside the grid which was taking ages. I am might investigate more about it but for the time being the end user is happy.
Wednesday, October 10, 2018 3:40 PM -
User1120430333 posted
PatriceSc
It's a bit weird. Behind the scene it still create SQL statements and uses ADO.NET so EF should run at a similar speed or a bit slower. There is nothing in EF that should make it "faster by design" than with ADO.NET hand written code.
Perhaps it is due to the grid I am using (which is DevExpress AsxpxGridview, by the way) I had a chat with their support and they suggested going using Entity Data Source as they are showing in their demo here. Displaying the grid itself was fine but it was the search inside the which was taking ages. I am might investigate more about it but for the time being the end user is happy.
EF uses collections and custom objects off of the ORM virtual object model.
http://lauteikkehn.blogspot.com/2012/03/datatable-vs-list.html
https://dzone.com/articles/reasons-move-datatables
https://www.codingblocks.net/programming/boxing-and-unboxing-7-deadly-sins/
Wednesday, October 10, 2018 4:13 PM