Message=オブジェクト名 'dbo.EGies' が無効です。 (Object name 'dbo.EGies' is Invalid)
Source=.Net SqlClient Data Provider"
From this message i came to know that my table name and the name used in the generated code is different. The table name in my DB is
"EGY_MST"
my model class is given below
public class EGY
{
[Key]
public string EgyCode { get; set; }
public string EgyName { get; set; }
public int St4Code { get; set; }
}
public class EGYDBContext : DbContext
{
public DbSet<EGY> EGYs { get; set; }
}
how the naming systems works in MVC. How to make the table name of exising DB and generated code names made same?
Saji dk
0 Points
6 Posts
System.Data.EntityCommandExecutionException was unhandled by user code
Apr 11, 2012 01:19 AM|LINK
Hi,
I am following the tutorial in the url below to build a sample application with my existing db.
http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part5-cs
Now i am getting an error as i mentioned in the Subject . If i see the inner exception i have the error below
"InnerException: System.Data.SqlClient.SqlException
Message=オブジェクト名 'dbo.EGies' が無効です。 (Object name 'dbo.EGies' is Invalid)
Source=.Net SqlClient Data Provider"
From this message i came to know that my table name and the name used in the generated code is different. The table name in my DB is
"EGY_MST"
my model class is given below
public class EGY { [Key] public string EgyCode { get; set; } public string EgyName { get; set; } public int St4Code { get; set; } } public class EGYDBContext : DbContext { public DbSet<EGY> EGYs { get; set; } }how the naming systems works in MVC. How to make the table name of exising DB and generated code names made same?
looking for a solution
Regards,
Saji dk
0 Points
6 Posts
Re: System.Data.EntityCommandExecutionException was unhandled by user code
Apr 11, 2012 05:03 AM|LINK
Hi,
I used [Table("table name")] annotation for my model class. Now it is working eventhough the i am getting another error like below
"The 'St4Code' property on 'EGY' could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'."
How to solve this problem? Which annotation i can use for it?
looking for a solution
Regards,
Saji dk
0 Points
6 Posts
Re: System.Data.EntityCommandExecutionException was unhandled by user code
Apr 11, 2012 05:14 AM|LINK
Hi all,
I figured it out. Thank you for all your time. I used int? instead of int.
Regards,
Saji