Entity Framework – Inheritance/Association – including Troubleshooting and comment on verbose SQL

See this video on Model Table Per Type

http://msdn.microsoft.com/en-us/data/cc765425.aspx

  1. Update Model from Database – Add Table
  2. Right-click Entity Add Inheritance
  3. Error 11009: Property ‘<>’ is not mapped
  4. Right-click Entity > Table Mapping > re map missing
  5. Running transformation: A member named ID cannot be defined in class DerivedClass. It is defined in ancestor class ParentClass.
  6. Delete it from DerivedClass

Error 3027: No mapping specified for the following EntitySet/AssociationSet – TableATableB

Error 11008: Association TableATableB is not mapped
EF is not expecting both a Foreign Key relationship and an association, see note at top of: http://msdn.microsoft.com/en-us/library/bb738488.aspx
Delete the association

Existing queries may then break as the Entity type no longer exists. So in my case Products is base type PadMain inherits from this. Used to have PadMains now PadMain EntityName is Products, so query on PadMains needs to change. From/To:

From b In context.PadMains
From b in context.Products1.OfType(Of PadMain)()

However if PadMain has subtypes then the SQL generated is verbose. If table is separated out in SQL then you just want the base table. If a field will appear in multiple related child tables then you will get duplications. In this scenario this is a major disadvantage of Entity Framework. Hopefully it will be fixed in future. For now I have removed my inheritance.

TFS Preview

I am on my way:

I have set up my account. Created a project. Created users. Download HotFix for VS2010. Connected to TFS from VS2010 on my machine. Added a solution and one project. Created a user story. Checked in the code. Created a build on my machine which is stored on TFS Preview. Started a new build. Build completed OK.

The only thing that has not worked is Home > Activities > “Open new instance of Visual Studio”. Perhaps this only works with VS2012.

Visual Studio Tips

 

  1. If at the bottom of a region you may think you need to go to the top before you can collapse the region. You can actually double-click the line just to the left of the code to collapse it. This is very subtle.

The file or directory is corrupt and non-readable. (possibly in Visual Studio and TFS Build broke)

Problem found

<drive>:\<folder> is not accessible    The file or directory is corrupt and non-readable.The file or directory is corrupt and non-readable. The file or directory \<folder> is corrupt and unreadable.    Please Run the Chkdsk utility.

Was causing build to fail. Some how system had created a badly named file RoqteOpsData where the q should have been a u

Resolution

http://support.microsoft.com/kb/176646

Attempt to repair the damaged file, folder or file system index using Chkdsk. To do so, follow these steps:

  1. Click Start, and then click Run.
  2. In the Open box, type chkdsk /f <drive>:,   where <drive> is the letter of the drive on which the damaged file,   folder or file system index exists.
  3. Click OK.

How do I … modify the appearance of a Windows.Forms.TableLayoutPanel at run-time

http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/thread/ad57487d-d7e0-4131-a388-cc3815809033/

The following adjusts the column width

Me.TableLayoutPanel1.ColumnStyles(0).Width = 10.0

The following gets the actual control. Making this invisible, leaves the table cell in place, same size.

Me.LayoutPanelGraph.GetControlFromPosition(colIndex, rowIndex).Visible = False

In my own code this is seen in SRS.Windows.Forms.ListBoxFilter

Get SQL table space – and store for KPI over time

See http://therightstuff.de/CommentView,guid,df930155-f60f-4f56-ab33-f1352ff091a1.aspx

For a single table

EXEC sp_spaceused ‘<schema>.<tablename>’

For database size

–See sql file for dbo.TableSpaceUsed
SET NOCOUNT ON DBCC UPDATEUSAGE(0) — DB size.
EXEC sp_spaceused– Table row counts and sizes.

For all tables

See http://codebetter.com/raymondlewallen/2005/03/25/using-sp_msforeachtable/
http://wp.me/p17IS4-ge

CREATE TABLE #t
(
[name] NVARCHAR(128)
,    [rows] CHAR(11)
,    reserved VARCHAR(18)
,     data VARCHAR(18)
,     index_size VARCHAR(18)
,    unused VARCHAR(18)
)

INSERT #t EXEC sp_msForEachTable ‘EXEC sp_spaceused ”?”’

–Optional, but I am now using a table I have created for storing this table size over time
DECLARE @SpoolID int SELECT @SpoolID =ISNULL((SELECTMAX(SpoolID)FROM dbo.TableSpaceUsed), 0)+ 1
–SELECT @SpoolID

INSERT INTO dbo.TableSpaceUsed (SpoolID, [name], [rows], reserved, reservedText, data, index_size, unused)
SELECT @SpoolID, name,rows,CAST(REPLACE(reserved,‘KB’,)ASint)AS reserved, reserved AS reservedText, data, index_size, unused
FROM  #t

SELECT * FROM #t ORDER BY CAST(REPLACE(reserved,‘KB’,)AS int) DESC— # of rows.

SELECT SUM(CAST([rows] ASint))AS [rows] FROM #t

DROP TABLE #t

Using sp_MSforeachtable

http://codebetter.com/raymondlewallen/2005/03/25/using-sp_msforeachtable/

See usage in http://wp.me/p17IS4-gc

How do I hide missing data values in DataVisualization.Charting.Chart e.g. Saturdays and Sundays

 

If data is missing for say days of weekend then the chart will by default still include these dates in the X values so there will be a not pretty gap. This can be corrected with:

Series.IsXValueIndexed = True

How do I set the DataVisualization.Charting.Chart Column Gap

The column gap is set on the:

Chart > Series > Misc > Point Width – default = 0.8 for no gap use 1

DataVisualization.Charting Cursors, Zooming, and Scrolling (Chart Controls)

 

I like the Zooming and Scrolling features of these Charts but find it difficult to find in the Chart Control. It is at:

Chart Areas > CursorX >

IsUserEnabled = True
IsUserSelectionEnabled = True

http://msdn.microsoft.com/en-us/library/dd456730