0

I am learning MVC 4 from O'Reilly book (Programming ASP.NET MVC4) and have followed its steps so now have a class as:

public class Auction
{
    public long Id { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public decimal StartPrice { get; set; }
    public decimal CurrentPrice { get; set; }
    //[Column(TypeName = "DateTime2")]
    public DateTime StartTime { get; set; }
    //[Column(TypeName = "DateTime2")]
    public DateTime EndTime { get; set; }
}

and as you know better I have to go with EF (eh) and when I run the code I get and error as

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

Yes, I know it is here on SOF and discussed but from the answers on SOF I found that i can do a conversion in the table. As you see I have commented out the attributes in the class since using them leads me to a new error as:

The model backing the 'eBayDataContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

Beside this situation: I cannot see any DB or table made in SQL Server. How can I locate the table/DB generated by EF? I have checked but nothing I do see here!

This is my connectionString

  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-eBay-20140404154307;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-eBay-20140404154307.mdf" providerName="System.Data.SqlClient" />
  </connectionStrings>

Thank you.

1 Answer 1

1

In Visual Studio 2010:

  1. View --> Server Explorer
  2. Click Connect to Database icon.
  3. Leave defaults and enter (LocalDb)\v11.0 for the Server name field.
  4. In the Connect to a database section at the bottom, click the down arrow for the dropdownlist (Select or enter a database name:) It will take a few seconds, but then you should see your database listed there (aspnet-eBay-20140404154307)
  5. Select your database and click OK.

You'll now have a new connection to your database in the Server Explorer window. You can expand this connection and navigate to your Tables.

Sign up to request clarification or add additional context in comments.

4 Comments

You must wrote ur server name in the list, not search for that.
Thanks but can you be more specific?
@Craig Thanks I followed that but there is no such a name in drop-down list. any idea? the reason I think the Db/Table are created is because when I change my class it throws: **The model backing the 'eBayDataContext' context has changed since the database was created. Consider using Code First Migrations to update the database (go.microsoft.com/fwlink/?LinkId=238269). **
OK finally after several minutes it showed up!!! i am new to EF but by far it acts strange and I'm not crazy about it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.