Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am a beginner to Entity Framework. In my project, I'm following a model-first approach, I created my tables and the associations between them, like in this screenshot:
For the Visual Studio mapping always takes the KF into account even if I don't ask.
Can someone help me overcome this problem?
below the code of the two entities
public partial class Currencies
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Currencies()
{
}
Thank you !
help me overcome this problem
which problem? This is how EF is supposed to work.
If you really want to query it yourself later, without an FK index, then replace the Currencies property with an Guid CurrencyId in ExchangeRate.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I tried to update model/table in the ORM but it still shows there even after updating it.
I don't know what is the problem in this even i have changed the table name and deleted my models using select all then delete in the ORM and removed EDMX as well but still same issue persists.
Found the solution to my answer as i was creating table without primary key so it didn't add it in the ORM.
Using primary key worked with me.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I'm working on a project in which i have to deal with Staff accounts and in Accounts details i have more then one enteries with same id and I want to delete single record from the list without effecting others row with same Id
You should make it unique first. You can, for example, use the id=id_index so in this case when you are deleting it is unique.
Also, if it is just removing from the interface you can use 'this' keyword inside change event by using jquery.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am trying to use this gigantic bloated monster of a library, Identity, but I don't want to use entity framework. So I got NHibernate.AspNet.Identity!
I think I'm almost athe point of getting it to work but I can't seem to figure out how to generate the schema for the DB.
I thought it would automatically populate the DB with tables on first run. I was wrong...
Does anyone know where I can generate/find the schema for the database? Thanks!
Have you tried to use SchemaExport or SchemaUpdate (supports migration) classes from NHibernate.Tool.hbm2ddl? You may find usage example at What is schemaExport in Fluent NHibernate? and Fluent NHibernate - Create database schema only if not existing
In a nutshell the code for FluentNHibernate looks something like (and is similar for XML-based configuartion)
Fluently.Configure()
.Database(/* configure database */)
.Mappings(/* mappings */)
.ExposeConfiguration(cfg => { new SchemaExport(cfg).Create(false, true); });
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am using ASP.NET Identity for login mechanism. In register Page I have to store some more details from another model also.
My Question is,
can I add details in my own table with system provided membership table(s) in same time?
Please guide me for the above thank you..
There is a RegisterViewModel (which isn't mapped to a database table) that you could extend with all the properties you need. It's located in Models/AccountViewModels.cs. Then in your AccountController, in the Register method, after the line that says if (result.Succeeded) you can add in your own code to put the extra data into the other 3 tables.
Question is a bit vague!
What do you mean by (my table)?
Is it included in the user identity database?
If so, then you will have to enable data migration of your dbContext (assuming u r using EF)
Then extend the dbContext DbSet<> to include any table you need.
If this doesn't answer your question, please edit your question with more information
Check this link
http://www.codeproject.com/Articles/674760/Code-First-Migration-and-Extending-Identity-Accoun
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
The question was about the concept of database first or code first.
When i'm using database first, how i can check if my database is already created and filled.
Thanks
Really, you are asking two different questions. Entity Framework is not a database administration tool and as such does not have any functionality for directly loading data from a spreadsheet.
If you research each part of your question separately, you might have more luck.
Seeding data with Entity Framework
Reading Excel Files with C#
Reply to comment:
if (!context.PostalCodes.Any())
{
IEnumerable<PostalCode> postalCodes = ReadPostalCodes();
foreach(var postalCode in postalCodes)
{
context.PostalCodes.Add(postalCode);
}
context.SaveChanges();
}