none
IF Beginner Question RRS feed

  • Question

  • namespace Harmony2015

    { public partial class BuildModel : Form { public BuildModel() { InitializeComponent(); } public class ImpedanceEl { public ImpedanceEl() { } public int Id { get; set; } public int Length { get; set; } public double Re_X { get; set; } // I am not sure what type of value impedance has } public class Power_Sys { public Power_Sys() { } public string Power_Sys_ID { get; set; } public ICollection<ImpedanceEl> ImpedanceEl { get; set; } } } namespace Power_System_Simulation_Harmonics { public class SystemContext : System.Data.Entity.DbContext { public SystemContext() : base() { } //PROBLEM OCCURS IN THE NEXT TWO LINES. public DbSet<ImpedanceEl> ImpedanceElements { get; set; } public DbSet<Power_Sys> PowerSystems { get; set; } } }

    I'm having some trouble with the code above.

    I'm working through the database tutorial at:

    http://www.entityframeworktutorial.net/code-first/setup-entity-framework-code-first-environment.aspx

    .

    It appears that I am missing a "class" definition,

    but I have defined the two classes above the code that has the problem.

    This seems a little mysterious.

    Can anyone help (please).

    Thank you.

    Thursday, September 17, 2015 3:00 PM

Answers

  • Hi LingJingLing,

    I guess you are getting this error message "The type or namespace name 'ImpedanceEl' could not be found (are you missing a using directive or an assembly reference?)". It was caused by the different namespace you are using in your project.

    Change "namespace Power_System_Simulation_Harmonics" to "namespace Harmony2015" can solve this problem. Please try it and let me know the result.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 18, 2015 3:23 AM
    Moderator