.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Newbie to EF - Inheritance

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net

Hi all-

Dipping my toes in the Entity Framework water and having a little trouble figuring out how to build in object inheritance to a model.

Here's the approach I've taken (mostly stolen from: http://www.robbagby.com/entity-framework/entity-framework-modeling-table-per-type-inheritance/)

1) Define a couple tables: ContentItem and News, give News a ForeignKey to ContentItemId

2) Import into VS2008 EF modeler by updating model from DB

3) Delete auto-created relationship (NOTE: instructions above instruct me to delete the property on the object representing the Foreign key... but it never shows in my modeler)

4) Define inheritance, News inherits from ContentItem

5) Map contentitemId to appropriate column in News mapping

6) Try to build


I end up with this:

Error    8    Error 3002: Problem in Mapping Fragment starting at line 1425: Potential runtime violation of table News's keys (News.NewsId): Columns (News.NewsId) are mapped to EntitySet ContentItem's properties (ContentItem.NewsId) on the conceptual side but they do not form the EntitySet's key properties (ContentItem.ContentItemId).
    C:\Projects\TAP\TAP.Domain\TAPModel.edmx    1426    15    TAP.Domain

View Complete Post

More Related Resource Links

connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

Master Pages: Master Your Site Design with Visual Inheritance and Page Templates


Master pages in ASP.NET 2.0 solve a problem many Web developers have been solving on their own with a variety of techniques for years - providing a single master template for an entire site. This article covers the details of master pages, discussing their usage and implementation and how they are a natural evolution of custom techniques developers are using today.

Fritz Onion

MSDN Magazine June 2004

newbie needs help with textbox


I have a textbox that a user is going to use to enter search information.  when the page loads, "search Phrase" will already be inside the box...my question is how do i make it so this text is already selected. 

 document.getIdFromElement("Textbox1").select();                   i've been told to use this java script but where do I put it and with what syntax.  also do i need to put page1. before the rest of it.  i am extremely new to this so please act like you are answering to a small child who needs concise directions.


thank you very much in advance

Total newbie question: Calling jQuery in an UpdatePanel?



Please forgive this ignorant question - I've used ASP.NET AJAX a good deal but I'm new to jQuery.  Specifically, is it possible to call or create jQuery events on the fly via an UpdatePanel?  For example, calling a jQuery modal or animating a Label (or <div> contained Literal), etc.

If anyone has any advice or could point me to some easy tutorials on mixing ASP.NET AJAX and jQuery, I'd greatly appreciate it. 



[newbie] How to return a data record from a webservice (wsdl)?



vs2010, .NET 4.0

I have a webmethod which I want to return a data record (for example: name, surename, address, age, zip etc)

I wonder how to accomplish this. I think the solution is about creating an object which contains all the records serialized. And then the webmethod returns this serialized object. I'm not 100% sure how to accomplish this, if some of you good provide me with some tips, tutorial or link to an article explaining it, that would be great

Browsing through an xml file [newbie]

I've setup this <asp:FormView> to read from an XML file which I created, however I noted that although the .xml file has two <article> </article> tags, the data control (FormView) only displays the first item when enabling pages.Is this a bug or am I missing something out? Source code available here. NOTES 1. XML file is valid according to this page., although, I still have to find out an appropriate XSLT format. Ideas?

SSAS newbie question

Hi Guys, I come from a SAP BW background, and i was wondering if i need to learn SSIS and SSRS together with SSAS in order to get a job? A insight into the current job market would also be helpfful. Thanks!

C# newbie stuck - trying to access column data in a SharePoint list in an SSIS script task

Hello, I'm sure this is the simplest question but I can't figure it out, even with Google's help. I am trying to stumble through some C# code in an SSIS script task and I am frustrated that I can't figure out how to do the easiest things.  I eventually want to find data in a column,and then use another list as a lookup to replace that value with another where the existing value matches a value in the lookup list.  So, the data in my (multiple choice) column might be "apples; bananas" and in another list I have a row that contains two columns, the first holding the value "Apples" and the second containing "Red Delicious" and my original column should read: "Red Delicious; bananas." But, alas, I can't even figure out how to see the data that is in a column. Here is my code: /*<br/> Microsoft SQL Server Integration Services Script Task<br/> Write scripts using Microsoft Visual C# 2008.<br/> The ScriptMain is the entry point class of the script.<br/> */<br/> <br/> using System;<br/> using System.Data;<br/> using Microsoft.SharePoint;<br/> using Microsoft.SqlServer.Dts.Runtime;<br/> using System.Windows.Forms;<br/> using Microsoft.SharePoint.Utilities;<br/> <br/> namespace ST_08becda4c05c49cd9f30ea76110076cd.csproj<br/> {<br/> [

Problems with inheritance in WCF

Hi, I've got some code written using remoting that I'm considering updating to use WCF as WCF has some pretty nice features, however I've been having real problems getting inheritance to work going across WCF using binary serialization, I created some simple test code to get my head round whats going on using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.ServiceModel; using System.ServiceModel.Channels; namespace Test { [ServiceContract] public interface IServer { [OperationContract] BaseType Get(); } public class Server : MarshalByRefObject, IServer { public BaseType Get() { return new InhertitedType(); } } [Serializable] public abstract class BaseType { public abstract string Name{ get;} } [Serializable] public class InhertitedType : BaseType { public override string Name{ get { return "Working"; } } } class Program { static int port=8888; static string ip = ""; static void Main(string[] args) { var binding = new NetTcpBinding(); var endpoint = new EndpointAddress(string.Format("net.tcp:/

Can someone explain this inheritance?

I am having trouble understanding the inheritance listed in http://msdn.microsoft.com/en-us/library/cc406686(office.12).aspx <%@ Page Debug="true" Language="C#" MasterPageFile="~/_admin/admin.master" Inherits="MSDN.SharePoint.Samples.WarmupJobManager, MSDN.SharePoint.Samples.SharePointWarmupJob, Version=, Culture=neutral, PublicKeyToken=7fd1d26c5854f031" %> It almost looks to me like two classes are being inherited - WarmUpJobManager AND SharepointWarmupJob. Is this correct?...or even possible?? Neither class is a partial class. Sorry I am new to this and was trying to deploy this example but the inheritance displayed here has me confused. Thanks in advance, Jake.

jQuery Flexigrid Plugin - newbie help

HiCan anyone support my attempt to use this jQuery plugin, or know where I can go to get some decent support? I am using a .ashx generic handler and returning xml data but the data won't show up in the html page, any ideas please ????<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="flexigrid/flexigrid.pack.js"></script> <link rel="Stylesheet" href="flexigrid/style.css" media="screen" /> <script type="text/javascript"> $("document").ready(function () { $("#flex1").flexigrid({ url: 'dac.ashx', dataType: 'xml', colModel: [ { display: 'ISO', name: 'iso', width: 40, sortable: true, align: 'center' }, { display: 'Name', name: 'name', width: 180, sortable: true, align: 'left' }, { display: 'Printable Name', name: 'printable_name', width: 12

How can I reset inheritance to regain controll of a subsite/subweb?

How can I reset inheritance to regain controll of a subsite/subweb?Kevin W. Gagel
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend