tag:blogger.com,1999:blog-6082652835152798567.post8478767477825833659..comments2024-03-28T00:58:12.736-07:00Comments on Sql server, .net and c# video tutorial: Part 29 - Using data transfer object as the model in mvcUnknownnoreply@blogger.comBlogger14125tag:blogger.com,1999:blog-6082652835152798567.post-4023875928738545172023-07-14T06:20:15.763-07:002023-07-14T06:20:15.763-07:00add [Key] above the name property in DepartmentTo...add [Key] above the name property in DepartmentTotal.cs and rebuild then add a viewpopeyenoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-24974582204329727442019-11-18T20:25:18.982-08:002019-11-18T20:25:18.982-08:00There was an error running the selected code gener...There was an error running the selected code generator:<br />'Unable to retrieve metadata for 'EntityFrameworkDemo.Models.DepartmentTotals', One or more validation errors were detected during model generation:<br /><br />Department:: EntityType 'Department' has no key Defined<br />Define the key for this EntityType.<br />DepartmentTotals:: EntityType 'DepartmentTotals' has no key defined. Define the key for this EntityType.<br />Departments: EntityType: EntitySet 'Departments' is based on type 'Department' that has no keys defined.<br />DepartmentsTotals: EntityType: EntitySet 'DepartmentTotals' is based on type 'DepartmentTotals' that has no keys defined.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-85087407322428427042019-02-03T21:00:53.828-08:002019-02-03T21:00:53.828-08:00Did you try building your project after adding the...Did you try building your project after adding the Key attribute? This error went away for me after building the project.<br />Also, the Name property will not be added to the view when you generate the view, so you will have to add it manually.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-25458875508425596552018-12-17T04:08:27.950-08:002018-12-17T04:08:27.950-08:00Though I added [Key] attribute I'm getting thi...Though I added [Key] attribute I'm getting this error:<br /><br />"One or more validation errors were detected during model generation" along with "Entity type has no key defined".<br /><br />Error is like this:<br /><br />There was an error running the selected code generator:<br />'Unable to retrieve metadata for 'EntityFrameworkDemo.Models.DepartmentTotals', One or more validation errors were detected during model generation:<br /><br />Department:: EntityType 'Department' has no key Defined<br />Define the key for this EntityType.<br />DepartmentTotals:: EntityType 'DepartmentTotals' has no key defined. Define the key for this EntityType.<br />Departments: EntityType: EntitySet 'Departments' is based on type 'Department' that has no keys defined.<br />DepartmentsTotals: EntityType: EntitySet 'DepartmentTotals' is based on type 'DepartmentTotals' that has no keys defined.<br /><br /><br />Please Help me to solve this.<br /><br />Thanks in advance.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-42503376159949839662018-12-17T03:16:44.519-08:002018-12-17T03:16:44.519-08:00Hi There,
While I was trying to create an View fo...Hi There,<br /><br />While I was trying to create an View for "EmployeesByDepartment" It was showing this error:<br /><br />There was an error running the selected code generator:<br />'Unable to retrieve metadata for 'EntityFrameworkDemo.Models.DepartmentTotals', One or more validation errors were detected during model generation:<br /><br />Department:: EntityType 'Department' has no key Defined<br />Define the key for this EntityType.<br />DepartmentTotals:: EntityType 'DepartmentTotals' has no key defined. Define the key for this EntityType.<br />Departments: EntityType: EntitySet 'Departments' is based on type 'Department' that has no keys defined.<br />DepartmentsTotals: EntityType: EntitySet 'DepartmentTotals' is based on type 'DepartmentTotals' that has no keys defined.<br /><br /><br />Please Help me to resolve this.<br /><br />Thanks in advance,<br />DivyaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-68195706595899871152018-02-15T03:16:44.606-08:002018-02-15T03:16:44.606-08:00everything is right in server when I run query ,bu...everything is right in server when I run query ,but query resulting in total as "1" for every department in visual studio<br />RHhttps://www.blogger.com/profile/18012884767955041586noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-19626679939563016252017-12-27T10:21:10.679-08:002017-12-27T10:21:10.679-08:00Hi Anonymous,
The SQL query is being executed by E...Hi Anonymous,<br />The SQL query is being executed by Entity Framework generated from LINQ you wrote.GSBhttps://www.blogger.com/profile/07595540149712024654noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-64435006308948381962017-12-23T08:51:11.309-08:002017-12-23T08:51:11.309-08:00Respected Venkat
I am too much confused by this co...Respected Venkat<br />I am too much confused by this code I have made this and it is also working but I am confused that where is the query to select the data and join the two table. Please guide me that what should I do first to understand these kind of codes<br /><br />RegardsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-40768991850469494242017-06-30T08:31:38.009-07:002017-06-30T08:31:38.009-07:00If you're getting an error trying to create yo...If you're getting an error trying to create your view, just add the [Key] attribute to the Name property of your DepartmentTotals class:<br /><br />using System.ComponentModel.DataAnnotations;<br /><br />namespace MVCDemo.Models<br />{<br /> public class DepartmentTotals<br /> {<br /> [Key]<br /> public string Name { get; set; }<br /> public int Total { get; set; }<br /> }<br />}Mike Bradyhttps://www.blogger.com/profile/05246080790726436836noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-90577078513489880832016-01-21T06:44:26.136-08:002016-01-21T06:44:26.136-08:00Hello Sir ,i m getting an error while tring to cre...Hello Sir ,i m getting an error while tring to create a DTO usin g code first EF ,its asking for Key ... plzz tell me how can i solve d issues ..plzz sir, upload a video by describing the DTO in details . <br />Samim Hussainnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-41877162419792727432015-05-10T05:01:55.832-07:002015-05-10T05:01:55.832-07:00Try without setting up any data context classTry without setting up any data context classNiyaskchttps://www.blogger.com/profile/12861314849333044417noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-33031203059278677702015-01-11T18:16:23.244-08:002015-01-11T18:16:23.244-08:00Hi Prahim,
How could I pass to the same View ID o...Hi Prahim,<br /><br />How could I pass to the same View ID of department to be available for making a link:<br />@Html.ActionLink(item.Name, "index", new { @id = item.DepId })<br /><br />Kind regardsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-65016883349986499852014-05-05T03:51:08.557-07:002014-05-05T03:51:08.557-07:00Hi Venkat,
I am getting an error
like this
Serv...Hi Venkat,<br /><br />I am getting an error<br />like this<br /><br /><br />Server Error in '/' Application.<br /><br />The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MvcDemo3.Models.Employee]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MvcDemo3.Models.DepartmentTotals]'.<br /><br />Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /><br />Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MvcDemo3.Models.Employee]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MvcDemo3.Models.DepartmentTotals]'.<br /><br />Source Error: <br /><br />An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.<br /><br /><br />please help meAnonymoushttps://www.blogger.com/profile/10038426174068108961noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-47405201993623397602013-06-03T22:21:49.393-07:002013-06-03T22:21:49.393-07:00Hello Sir G
As i have both the version of VS, i.e ...Hello Sir G<br />As i have both the version of VS, i.e VS 2010 & VS 2012 in latest version mvc 3&4 are included by default so i think there is no need to install separately mvc 4.<br />please tell me mian feature of vs 2012 over vs 2010/<br />Dear Sir G you are doing a very good and outstanding job.<br />May GOD bless you more and more and.........<br />Thank you so much Sir G!!!Shaiz Awanhttps://www.blogger.com/profile/03635366050877901518noreply@blogger.com